home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / dosref22.zip / CHAPTER.004 < prev    next >
Text File  |  1991-12-20  |  115KB  |  2,213 lines

  1.  
  2.        **  Programmer's Technical Reference for MSDOS and the IBM PC **
  3.                 USA copyright TXG 392-616  ALL RIGHTS RESERVED
  4. ───────────────────────────────┤ DOSREF (tm) ├────────────────────────────────
  5.                      ISBN 1-878830-02-3 (disk-based text)
  6.                     Copyright (c) 1987, 1991 Dave Williams
  7.                         ┌─────────────────────────────┐
  8.                         │ Shareware Version, 12/20/91 │
  9.                         │  Please Register Your Copy  │
  10.                         └─────────────────────────────┘
  11.  
  12.  
  13.                            C H A P T E R    F O U R
  14.  
  15.                        DOS INTERRUPTS AND FUNCTION CALLS
  16.  
  17.        note: The registered version of this chapter is twice this size.
  18.  
  19.  
  20.  
  21. DOS REGISTERS├─────────────────────────────────────────────────────────────────
  22.  
  23.  DOS uses the following registers, pointers, and flags when it executes
  24. interrupts and function calls:
  25. ┌───────────────────┬──────────┬───────────────────────────────────────────────┐
  26. │GENERAL REGISTERS  │ register │                  definition                   │
  27. │                   ├──────────┼───────────────────────────────────────────────┤
  28. │                   │    AX    │  accumulator (16 bit)                         │
  29. │                   │    AH    │  accumulator high-order byte (8 bit)          │
  30. │                   │    AL    │  accumulator low order byte (8 bit)           │
  31. │                   │    BX    │  base (16 bit)                                │
  32. │                   │    BH    │  base high-order byte (8 bit)                 │
  33. │                   │    BL    │  base low-order byte (8 bit)                  │
  34. │                   │    CX    │  count (16 bit)                               │
  35. │                   │    CH    │  count high order byte (8 bit)                │
  36. │                   │    CL    │  count low order byte (8 bit)                 │
  37. │                   │    DX    │  data (16 bit)                                │
  38. │                   │    DH    │  date high order byte (8 bit)                 │
  39. │                   │    DL    │  data low order byte (8 bit)                  │
  40. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  41. │SEGMENT REGISTERS  │ register │                  definition                   │
  42. │                   ├──────────┼───────────────────────────────────────────────┤
  43. │                   │    CS    │  code  segment (16 bit)                       │
  44. │                   │    DS    │  data  segment (16 bit)                       │
  45. │                   │    SS    │  stack segment (16 bit)                       │
  46. │                   │    ES    │  extra segment (16 bit)                       │
  47. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  48. │INDEX REGISTERS    │ register │                  definition                   │
  49. │                   ├──────────┼───────────────────────────────────────────────┤
  50. │                   │    DI    │  destination index (16 bit)                   │
  51. │                   │    SI    │  stack       index (16 bit)                   │
  52. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  53. │SEGMENT REGISTERS  │ register │                  definition                   │
  54. │                   ├──────────┼───────────────────────────────────────────────┤
  55. │                   │    CS    │  code  segment (16 bit)                       │
  56. │                   │    DS    │  data  segment (16 bit)                       │
  57. │                   │    SS    │  stack segment (16 bit)                       │
  58. │                   │    ES    │  extra segment (16 bit)                       │
  59. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  60. │INDEX REGISTERS    │ register │                  definition                   │
  61. │                   ├──────────┼───────────────────────────────────────────────┤
  62. │                   │    DI    │  destination index (16 bit)                   │
  63. │                   │    SI    │  stack       index (16 bit)                   │
  64. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  65. │POINTERS           │ register │                  definition                   │
  66. │                   ├──────────┼───────────────────────────────────────────────┤
  67. │                   │    SP    │  stack pointer (16 bit)                       │
  68. │                   │    BP    │  base pointer (16 bit)                        │
  69. │                   │    IP    │  instruction pointer (16 bit)                 │
  70. ├───────────────────┴──────────┴───────────────────────────────────────────────┤
  71. │FLAGS                   AF, CF, DF, IF, OF, PF, SF, TF, ZF                    │
  72. └──────────────────────────────────────────────────────────────────────────────┘
  73.  
  74.  These registers, pointers, and flags are "lowest common denominator" 8088-8086
  75. CPU oriented. DOS makes no attempt to use any of the special or enhanced
  76. instructions availible on the later CPUs which will execute 8088 code, such as
  77. the 80186, 80286, 80386, or NEV V20, V30, V40, or V50.
  78.  
  79.  When DOS takes control after a function call, it switches to an internal
  80. stack. Registers which are not used to return information (other than AX) are
  81. preserved. The calling program's stack must be large enough to accomodate the
  82. interrupt system - at least 128 bytes in addition to other interrupts.
  83.  DOS actually maintains three stacks -
  84. stack 1: 384 bytes (in DOS 3.1)
  85.          for functions 00h and for 0Dh and up, and for ints 25h and 26h.
  86.  
  87. stack 2: 384 bytes (in DOS 3.1)
  88.          for function calls 01h through 0Ch.
  89.  
  90. stack 3: 48 bytes (in DOS 3.1)
  91.          for functions 0Dh and above. This stack is the initial stack used by
  92.          the int 21h handler before it decides which of the other two to use.
  93.          It is also used by function 59h (get extended error), and 01h to 0Ch if
  94.          they are called during an int 24h (critical error) handler. Functions
  95.          33h (get/set break flag), 50h (set process ID), 51h (get process ID)
  96.          and 62h (get PSP address) do not use any DOS stack under DOS 3.x
  97.          (under 2.x, 50h and 51h use stack number 2).
  98.  
  99.  IBM and Microsoft made a change back in DOS 3.0 or 3.1 to reduce the size of
  100. DOS. They reduced the space allocated for scratch areas when interrupts are
  101. being processed. The default seems to vary with the DOS version and the
  102. machine, but 8 stack frames seems to ring a bell. That means that if you get
  103. more than 8 interrupts at the same time, clock, disk, printer spooler,
  104. keyboard, com port, etc., the system will crash. It seems to happen usually on
  105. a network. STACKS=16,256 means allow 16 interrupts to interrupt each other and
  106. allow 256 bytes for each for scratch area. Eight is marginal.
  107.  
  108.  DOS 3.2 does some different stack switching than previous versions. The
  109. interrupts which are switched are 02h, 08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 70h,
  110. 72h, 73h, 74h, 75h, 76h, and 77h. DOS 3.2 has a special check in the
  111. initialization code for a PCjr and don't enable stack switching on that machine.
  112.  
  113.  
  114.  
  115. INTERRUPTS├────────────────────────────────────────────────────────────────────
  116.  
  117.  Microsoft recommends that a program wishing to examine or set the contents of
  118. any interrupt vector use the DOS function calls 35h and 25h provided for those
  119. purposes and avoid referencing the interrupt vector locations directly.
  120.  DOS reserves interrupt numbers 20h to 3Fh for its own use. This means absolute
  121. memory locations 80h to 0FFh are reserved by DOS. The defined interrupts are as
  122. follows with all values in hexadecimal.
  123.  
  124.  
  125. ┌─────────────────────────────────────────────────────────────────────────────┐
  126. │Interrupt 21h  Function Call Request                                         │
  127. └─────────────────────────────────────────────────────────────────────────────┘
  128. (0:0084h)
  129.  DOS provides a wide variety of function calls for character device I/O, file
  130. management, memory management, date and time functions,execution of other
  131. programs, and more. They are grouped as follows:
  132.  
  133.           call              description
  134.         00h             program terminate
  135.         01h-0Ch         character device I/O, CP/M compatibility format
  136.         0Dh-24h         file management,      CP/M compatibility format
  137.         25h-26h         nondevice functions,  CP/M compatibility format
  138.         27h-29h         file management,      CP/M compatibility format
  139.         2Ah-2Eh         nondevice functions,  CP/M compatibility format
  140.         2Fh-38h         extended functions
  141.         39h-3Bh         directory group
  142.         3Ch-46h         extended file management
  143.         47h             directory group
  144.         48h-4Bh         extended memory management
  145.         54h-57h         extended functions
  146.         5Eh-5Fh         networking
  147.         60h-62h         extended functions
  148.         63h-66h         enhanced foreign language support
  149.  
  150.  
  151. List of DOS services:   * = undocumented
  152.         00h     terminate program
  153.         01h     get keyboard input
  154.         02h     display character to STDIO
  155.         03h     get character from STDAUX
  156.         04h     output character to STDAUX
  157.         05h     output character to STDPRN
  158.         06h     direct console I/O - keyboard to screen
  159.         07h     get char from std I/O without echo
  160.         08h     get char from std I/O without echo, checks for ^C
  161.         09h     display a string to STDOUT
  162.         0Ah     buffered keyboard input
  163.         0Bh     check STDIN status
  164.         0Ch     clear keyboard buffer and invoke keyboard function
  165.         0Dh     flush all disk buffers
  166.         0Eh     select disk
  167.         0Fh     open file with File Control Block
  168.         10h     close file opened with File Control Block
  169.         11h     search for first matching file entry
  170.         12h     search for next matching file entry
  171.         13h     delete file specified by File Control Block
  172.         14h     sequential read from file specified by File Control Block
  173.         15h     sequential write to file specified by File Control Block
  174.         16h     find or create firectory entry for file
  175.         17h     rename file specified by file control block
  176.         18h*    unknown
  177.         19h     return current disk drive
  178.         1Ah     set disk transfer area (DTA)
  179.         1Bh     get current disk drive FAT
  180.         1Ch     get disk FAT for any drive
  181.         1Dh*    unknown
  182.         1Eh*    unknown
  183.         1Fh*    read DOS disk block, default drive
  184.         20h*    unknown
  185.         21h     random read from file specified by FCB
  186.         22h     random write to file specified by FCB
  187.         23h     return number of records in file specified by FCB
  188.         24h     set relative file record size field for file specified by FCB
  189.         25h     set interrupt vector
  190.         26h     create new Program Segment Prefix (PSP)
  191.         27h     random file block read from file specified by FCB
  192.         28h     random file block write to file specified by FCB
  193.         29h     parse the command line for file name
  194.         2Ah     get the system date
  195.         2Bh     set the system date
  196.         2Ch     get the system time
  197.         2Dh     set the system time
  198.         2Eh     set/clear disk write VERIFY
  199.         2Fh     get the Disk Transfer Address (DTA)
  200.         30h     get DOS version number
  201.         31h     TSR, files opened remain open
  202.         32h*    read DOS Disk Block
  203.         33h     get or set Ctrl-Break
  204.         34h*    INDOS  Critical Section Flag
  205.         35h     get segment and offset address for an interrupt
  206.         36h     get free disk space
  207.         37h*    get/set option marking character (SWITCHAR)
  208.         38h     return country-dependent information
  209.         39h     create subdirectory
  210.         3Ah     remove subdirectory
  211.         3Bh     change current directory
  212.         3Ch     create and return file handle
  213.         3Dh     open file and return file handle
  214.         3Eh     close file referenced by file handle
  215.         3Fh     read from file referenced by file handle
  216.         40h     write to file referenced by file handle
  217.         41h     delete file
  218.         42h     move file pointer (move read-write pointer for file)
  219.         43h     set/return file attributes
  220.         44h     device IOCTL (I/O control) info
  221.         45h     duplicate file handle
  222.         46h     force a duplicate file handle
  223.         47h     get current directory
  224.         48h     allocate memory
  225.         49h     release allocated memory
  226.         4Ah     modify allocated memory
  227.         4Bh     load or execute a program
  228.         4Ch     terminate prog and return to DOS
  229.         4Dh     get return code of subprocess created by 4Bh
  230.         4Eh     find first matching file
  231.         4Fh     find next matching file
  232.         50h*    set new current Program Segment Prefix (PSP)
  233.         51h*    puts current PSP into BX
  234.         52h*    pointer to the DOS list of lists
  235.         53h*    translates BPB (Bios Parameter Block, see below)
  236.         54h     get disk verification status (VERIFY)
  237.         55h*    create PSP: similar to function 26h
  238.         56h     rename a file
  239.         57h     get/set file date and time
  240.         58h     get/set allocation strategy             (DOS 3.x)
  241.         59h     get extended error information
  242.         5Ah     create a unique filename
  243.         5Bh     create a DOS file
  244.         5Ch     lock/unlock file contents
  245.         5Dh*    network
  246.         5Eh*    network printer
  247.         5Fh*    network redirection
  248.         60h*    parse pathname
  249.         61h*    unknown
  250.         62h     get program segment prefix (PSP)
  251.         63h*    get lead byte table                     (DOS 2.25)
  252.         64h*    unknown
  253.         65h     get extended country information        (DOS 3.3)
  254.         66h     get/set global code page table          (DOS 3.3)
  255.         67h     set handle count                        (DOS 3.3)
  256.         68h     commit file                             (DOS 3.3)
  257.         69h     disk serial number                      (DOS 4.0)
  258.         6Ah     unknown
  259.         6Bh     unknown
  260.         6Ch     extended open/create                    (DOS 4.0)
  261.  
  262.  
  263. CALLING THE DOS SERVICES├──────────────────────────────────────────────────────
  264.  
  265.  The DOS services are invoked by placing the number of the desired function in
  266. register AH, subfunction in AL, setting the other registers to any specific
  267. requirements of the function, and invoking int 21h.
  268.  
  269.  On return, the requested service will be performed if possible. Most codes
  270. will return an error; some return more information. Details are contained in
  271. the listings for the individual functions. Extended error return may be
  272. obtained by calling function 59h (see 59h).
  273.  
  274.  Register settings listed are the ones used by DOS. Some functions will return
  275. with garbage values in unused registers. Do not test for values in unspecified
  276. registers; your program may exhibit odd behavior.
  277.  
  278.  DS:DX pointers are the data segment register (DS) indexed to the DH and DL
  279. registers (DX). DX always contains the offset address, DS contains the segment
  280. address.
  281.  
  282.  The File Control Block services (FCB services) were part of DOS 1.0. Since
  283. the release of DOS 2.0, Microsoft has recommended that these services not be
  284. used. A set of considerably more enhanced services (handle services) were
  285. introduced with DOS 2.0. The handle services provide support for wildcards and
  286. subdirectories, and enhanced error detection via function 59h.
  287.  
  288.  The data for the following calls was compiled from various Intel, Microsoft,
  289. IBM, and other publications. There are many subtle differences between MSDOS
  290. and PCDOS and between the individual versions. Differences between the
  291. versions are noted as they occur.
  292.  
  293.  There are various ways of calling the DOS functions. For all methods, the
  294. function number is loaded into register AH, subfunctions and/or parameters are
  295. loaded into AL or other registers, and call int 21 by one of the following
  296. methods:
  297.  A) call interrupt 21h directly  (the recommended procedure)
  298.  B) perform a long call to offset 50h in the program's PSP.
  299.      1) This method will not work under DOS 1.x
  300.      2) Though recommended by Microsoft for DOS 2.0, this method takes more
  301.         time and is no longer recommended.
  302.  C) place the function number in CL and perform an intrasegment call to
  303.     location 05h in the current code segment. This location contains a long
  304.     call to the DOS function dispatcher.
  305.      1) IBM recommends this method be used only when using existing programs
  306.         written for different calling conventions. (such as converting CP/M
  307.         programs). This method should be avoided unless you have some specific
  308.         use for it.
  309.      2) AX is always destroyed by this method.
  310.      3) This method is valid only for functions 00h-24h.
  311.  
  312.  There are also various ways of exiting from a program. (assuming it is not
  313. intended to be a TSR). All methods except call 4Ch must ensure that the
  314. segment register contains the segment address of the PSP.
  315.  A) Interrupt 21h, function 4Ch (Terminate with Result Code). This is the
  316.     "official" recommended method of returning to DOS.
  317.  B) Interrupt 21h, function 00h (Exit Program). This is the early style
  318.     int 21 function call. It simply calls int 20h.
  319.  C) Interrupt 20h (Exit).
  320.  D) A JMP instruction to offset 00h (int 20h vector) in the Program Segment
  321.     Prefix. This is just a roundabout method to call int 20h. This method
  322.     was set up in DOS 1.0 for ease of conversion for CP/M programs. It is no
  323.     longer recommended for use.
  324.  E) A JMP instruction to offset 05h (int 21 vector) in the Program Segment
  325.     Prefix, with AH set to 00h or 4Ch. This is another CP/M type function.
  326.  
  327.  
  328.  
  329.  
  330. INT 21H   DOS services
  331.           Function (hex)
  332.  
  333. * Indicates Functions not documented in the IBM DOS Technical Reference.
  334.  Note some functions have been documented in other Microsoft or licensed OEM
  335. documentation.
  336.  
  337.  
  338. Function  00h   Terminate Program
  339.       Ends program, updates, FAT, flushes buffers, restores registers
  340. entry   AH      00h
  341.         CS      segment address of PSP
  342. return  none
  343. note 1) Program must place the segment address of the PSP control block in CS
  344.         before calling this function.
  345.      2) The terminate, ctrl-break,and critical error exit addresses (0Ah, 0Eh,
  346.         12h) are restored to the values they had on entry to the terminating
  347.         program, from the values saved in the program segment prefix at
  348.         locations PSP:000Ah, PSP:000Eh, and PSP:0012h.
  349.      3) All file buffers are flushed and the handles opened by the process are
  350.         closed.
  351.      4) Any files that have changed in length and are not closed are not
  352.         recorded properly in the directory.
  353.      5) Control transfers to the terminate address.
  354.      6) This call performs exactly the same function as int 20h.
  355.      7) All memory used by the program is returned to DOS.
  356.  
  357.  
  358. Function  01h     Get Keyboard Input
  359.         Waits for char at STDIN (if nescessary), echoes to STDOUT
  360. entry   AH      01h
  361. return  AL      ASCII character from STDIN (8 bits)
  362. note 1) Checks char for Ctrl-C, if char is Ctrl-C, executes int 23h.
  363.      2) For function call 06h, extended ASCII codes require two function calls.
  364.         The first call returns 00h as an indicator that the next call will be an
  365.         extended ASCII code.
  366.      3) Input and output are redirectable. If redirected, there is no way to
  367.         detect EOF.
  368.  
  369.  
  370. Function  02h   Display Output
  371.       Outputs char in DL to STDOUT
  372. entry   AH      02h
  373.         DL      8 bit data (usually ASCII character)
  374. return  none
  375. note 1) If char is 08 (backspace) the cursor is moved 1 char to the left
  376.         (nondestructive backspace).
  377.      2) If Ctrl-C is detected after input, int 23h is executed.
  378.      3) Input and output are redirectable. If redirected, there is no way to
  379.         detect disk full.
  380.  
  381.  
  382. Function  03h   Auxiliary Input
  383.       Get (or wait until) character from STDAUX
  384. entry   AH      03h
  385. return  AL      char from auxiliary device
  386. note 1) AUX, COM1, COM2 is unbuffered and not interrupt driven
  387.      2) This function call does not return status or error codes. For greater
  388.         control it is recommended that you use ROM BIOS routine (int 14h) or
  389.         write an AUX device driver and use IOCTL.
  390.      3) At startup, PC-DOS initializes the first auxiliary port (COM1) to 2400
  391.         baud, no parity, one stop bit, and an 8-bit word. MSDOS may differ.
  392.      4) If Ctrl-C is has been entered from STDIN, int 23h is executed.
  393.  
  394.  
  395. Function  04h   Auxiliary Output
  396.       Write character to STDAUX
  397. entry   AH      04h
  398.         DL      char to send to AUX
  399. return  none
  400. note 1) This function call does not return status or error codes. For greater
  401.         control it is recommended that you use ROM BIOS routine (int 14h) or
  402.         write an AUX device driver and use IOCTL.
  403.      2) If Ctrl-C is has been entered from STDIN, int 23h is executed.
  404.      3) Default is COM1 unless redirected by DOS.
  405.      4) If the device is busy, this function will wait until it is ready.
  406.  
  407.  
  408. Function  05h   Printer Output
  409.       Write character to STDPRN
  410. entry   AL      05h
  411.         DL      character to send
  412. return  none
  413. note 1) If Ctrl-C is has been entered from STDIN, int 23h is executed.
  414.      2) Default is PRN or LPT1 unless redirected with the MODE command.
  415.      3) If the printer is busy, this function will wait until it is ready.
  416.  
  417.  
  418. Function  06h   Direct Console I/O
  419.       Get character from STDIN; echo character to STDOUT
  420. entry   AH      06h
  421.         DL      0FFh for console input, or 00h-0FEh for console output
  422. return  ZF      set   (1) = no character
  423.                 clear (0) = character recieved
  424.         AL      character
  425. note 1) Extended ASCII codes require two function calls. The first call returns
  426.         00h to indicate the next call will return an extended code.
  427.      2) If DL is not 0FFh, DL is assumed to have a valid character that is
  428.         output to STDOUT.
  429.      3) This function does not check for Ctrl-C or Ctrl-PrtSc.
  430.      4) Does not echo input to screen
  431.      5) If I/O is redirected, EOF or disk full cannot be detected.
  432.  
  433.  
  434. Function  07h   Direct Console Input Without Echo         (does not check BREAK)
  435.       Get or wait for char at STDIN, returns char in AL
  436. entry   AH      07h
  437. return  AL      character from standard input device
  438. note 1) Extended ASCII codes require two function calls. The first call returns
  439.         00h to indicate the next call will return an extended code.
  440.      2) No checking for Ctrl-C or Ctrl-PrtSc is done.
  441.      3) Input is redirectable.
  442.  
  443.  
  444. Function  08h   Console Input Without Echo                (checks BREAK)
  445.       Get or Wait for char at STDIN, return char in AL
  446. entry   AH      08h
  447. return  AL      char from standard input device
  448. note 1) Char is checked for ctrl-C. If ctrl-C is detected, executes int 23h.
  449.      2) For function call 08h, extended ASCII characters require two function
  450.         calls. The first call returns 00h to signify an extended ASCII code.
  451.         The next call returns the actual code.
  452.      3) Input is redirectable. If redirected, there is no way to check EOF.
  453.  
  454.  
  455. Function  09h   Print String
  456.       Outputs Characters in the Print String to the STDOUT
  457. entry   AH      09h
  458.         DS:DX   pointer to the Character String to be displayed
  459. return  none
  460. note 1) The character string in memory must be terminated by a $ (24h)
  461.         The $ is not displayed.
  462.      2) Output to STDOUT is the same as function call 02h.
  463.  
  464.  
  465. Function  0Ah   Buffered Keyboard Input
  466.       Reads characters from STDIN and places them in the buffer beginning
  467.       at the third byte.
  468. entry   AH      0Ah
  469.         DS:DX   pointer to an input buffer
  470. return  none
  471. note 1) Min buffer size = 1, max = 255
  472.      2) Char is checked for ctrl-C. If ctrl-C is detected, executes int 23h.
  473.      3) Format of buffer DX:
  474.         byte       contents
  475.          1      Maximum number of chars the buffer will take, including CR.
  476.                 Reading STDIN and filling the buffer continues until a carriage
  477.                 return (<Enter> or 0Dh) is read. If the buffer fills to one less
  478.                 than the maximum number the buffer can hold, each additional
  479.                 number read is ignored and ASCII 7 (BEL) is output to the
  480.                 display until a carriage return is read. (you must set this
  481.                 value)
  482.          2      Actual number of characters received, excluding the carriage
  483.                 return, which is always the last character. (the function sets
  484.                 this value)
  485.          3-n    Characters received are placed into the buffer starting here.
  486.                 Buffer must be at least as long as the number in byte 1.
  487.      4) Input is redirectable. If redirected, there is no way to check EOF.
  488.      5) The string may be edited with the standard DOS editing commands as it
  489.         is being entered.
  490.      6) Extended ASCII characters are stored as 2 bytes, the first byte being
  491.         zero.
  492.  
  493.  
  494. Function  0Bh   Check Standard Input (STDIN) status
  495.       Checks for character availible at STDIN
  496. entry   AH      0Bh
  497. return  AL      0FFh    if a character is availible from STDIN
  498.                 00h     if no character is availible from STDIN
  499. note 1) Checks for Ctrl-C. If Ctrl-C is detected, int 23h is executed
  500.      2) Input can be redirected.
  501.      3) Checks for character only, it is not read into the application
  502.      4) IBM reports that this call does not work properly under the DOSSHELL
  503.         program in DOS 4.00 and 4.01. DOSSHELL will return all zeroes. This
  504.         function works correctly from the command line or application.
  505.  
  506.  
  507. Function  0Ch   Clear Keyboard Buffer & Invoke a Keyboard Function       (FCB)
  508.       Dumps buffer, executes function in AL (01h,06h,07h,08h,0Ah only)
  509. entry   AH      0Ch
  510.         AL      function number (must be 01h, 06h, 07h, 08h, or 0Ah)
  511. return  AL      00h     buffer was flushed, no other processing performed
  512.                 other   any other value has no meaning
  513. note 1) Forces system to wait until a character is typed.
  514.      2) Flushes all typeahead input, then executes function specified by AL (by
  515.         moving it to AH and repeating the int 21 call).
  516.      3) If AL contains a value not in the list above, the keyboard buffer is
  517.         flushed and no other action is taken.
  518.  
  519.  
  520. Function  0Dh   Disk Reset
  521.       Flushes all currently open file buffers to disk
  522. entry   AH      0Dh
  523. return          none
  524. note 1) Does not close files. Does not update directory entries; files changed
  525.         in size but not closed are not properly recorded in the directory
  526.      2) Sets DTA address to DS:0080h
  527.      3) Should be used before a disk change, Ctrl-C handlers, and to flush
  528.         the buffers to disk.
  529.  
  530.  
  531. Function  0Eh   Select Disk
  532.       Sets the drive specified in DL (if valid) as the default drive
  533. entry   AL      0Eh
  534.         DL      new default drive number (0=A:,1=B:,2=C:,etc.)
  535. return  AL      total number of logical drives (not nescessarily physical)
  536. note 1) For DOS 1.x and 2.x, the minimum value for AL is 2.
  537.      2) For DOS 3.x and 4.x, the minimum value for AL is 5.
  538.      3) The drive number returned is not nescessarily a valid drive.
  539.      4) For DOS 1.x: 16 logical drives are availible, A-P.
  540.         For DOS 2.x: 63 logical drives are availible. (Letters are only used for
  541.                      the first 26 drives. If more than 26 logical drives are
  542.                      used, further drive letters will be other ASCII characters
  543.                      ie {,], etc.
  544.         For DOS 3.x: 26 logical drives are availible, A-Z.
  545.         For DOS 4.x: 26 logical drives are availible, A-Z.
  546.  
  547.  
  548. Function  0Fh   Open Disk File                                            (FCB)
  549.       Searches current directory for specified filename and opens it
  550. entry   AH      0Fh
  551.         DS:DX   pointer to an unopened FCB
  552. return  AL      00h     if file found
  553.                 0FFh    if file not not found
  554. note 1) If the drive code was 0 (default drive) it is changed to the actual
  555.         drive used (1=A:,2=B:,3=C:, etc). This allows changing the default drive
  556.         without interfering with subsequent operations on this file.
  557.      2) The current block field (FCB bytes C-D, offset 0Ch) is set to zero.
  558.      3) The size of the record to be worked with (FCB bytes E-F, offset 0Eh) is
  559.         set to the system default of 80h. The size of the file (offset 10h) and
  560.         the date (offset 14h) are set from information obtained in the root
  561.         directory. You can change the default value for the record size (FCB
  562.         bytes E-F) or set the random record size and/or current record field.
  563.         Perform these actions after the open but before any disk operations.
  564.      4) The file is opened in compatibility mode.
  565.      5) Microsoft recommends handle function call 3Dh be used instead.
  566.      6) This call is also used by the APPEND command in DOS 3.2+
  567.      7) Before performing a sequential disk operation on the file, you must
  568.         set the Current Record field (offset 20h). Before performing a random
  569.         disk operation on the file, you must set the Relative Record field
  570.         (offset 21h). If the default record size of 128 bytes is incorrect, set
  571.         it to the correct value.
  572.  
  573.  
  574. Function  10h  Close File                                              (FCB)
  575.      Closes a File After a File Write
  576. entry   AH      10h
  577.         DS:DX   pointer to an opened FCB
  578. return  AL      00h     if the file is found and closed
  579.                 0FFh    if the file is not found in the current directory
  580. note 1) This function call must be done on open files that are no longer needed,
  581.         and after file writes to insure all directory information is updated.
  582.      2) If the file is not found in its correct position in the current
  583.         directory, it is assumed that the diskette was changed and AL returns
  584.         0FFh. This error return is reportedly not completely reliable with DOS
  585.         version 2.x.
  586.      3) If found, the directory is updated to reflect the status in the FCB, the
  587.         buffers to that file are flushed, and AL returns 00h.
  588.  
  589.  
  590. Function  11h   Search For First Matching Entry                           (FCB)
  591.       Searches current disk & directory for first matching filename
  592. entry   AH      11h
  593.         DS:DX   pointer to address of FCB
  594. return  AL      00h     successful match
  595.                 0FFh    no matching filename found
  596. note 1) The FCB may contain the wildcard character ? under Dos 2.x, and ? or *
  597.         under 3.x and 4.x.
  598.      2) The original FCB at DS:DX contains information to continue the search
  599.         with function 12h, and should not be modified.
  600.      3) If a matching filename is found, AL returns 00h and the locations at the
  601.         Disk Transfer Address are set as follows:
  602.         a) If the FCB provided for searching was an extended FCB, then the first
  603.            byte at the disk transfer address is set to 0FFh followed by 5 bytes
  604.            of zeroes, then the attribute byte from the search FCB, then the
  605.            drive number used (1=A, 2=B, etc) then the 32 bytes of the directory
  606.            entry. Thus, the disk transfer address contains a valid unopened FCB
  607.            with the same search attributes as the search FCB.
  608.         b) If the FCB provided for searching was a standard FCB, then the first
  609.            byte is set to the drive number used (1=A,2=b,etc), and the next 32
  610.            bytes contain the matching directory entry. Thus, the disk transfer
  611.            address contains a valid unopened normal FCB.
  612.      4) If an extended FCB is used, the following search pattern is used:
  613.         a) If the FCB attribute byte is zero, only normal file entries are
  614.            found. Entries for volume label, subdirectories, hidden or system
  615.            files, are not returned.
  616.         b) If the attribute byte is set for hidden or system files, or
  617.            subdirectory entries, it is to be considered as an inclusive search.
  618.            All normal file entries plus all entries matching the specified
  619.            attributes are returned. To look at all directory entries except the
  620.            volume label, the attribute byte may be set to hidden + system +
  621.            directory (all 3 bits on).
  622.         c) If the attribute field is set for the volume label, it is considered
  623.            an exclusive search, and ONLY the volume label entry is returned.
  624.      5) This call is also used by the APPEND command in DOS 3.2+
  625.  
  626.  
  627. Function  12h   Search For Next Entry Using FCB                          (FCB)
  628.       Search for next matching filename
  629. entry   AH      12h
  630.         DS:DX   pointer to the unopened FCB specified from the previous Search
  631.                 First (11h) or Search Next (12h)
  632. return  AL      00h     if matching filename found
  633.                 0FFh    if matching filename was not found
  634. note 1) After a matching filename has been found using function call 11h,
  635.         function 12h may be called to find the next match to an ambiguous
  636.         request. For DOS 2.x, ?'s are allowed in the filename. For DOS 3.x
  637.         and 4.x, global (*) filename characters are allowed.
  638.      2) The DTA contains info from the previous Search First or Search Next.
  639.      3) All of the FCB except for the name/extension field is used to keep
  640.         information nescessary for continuing the search, so no disk operations
  641.         may be performed with this FCB between a previous function 11h or 12h
  642.         call and this one.
  643.      4) If the file is found, an FCB is created at the DTA address and set up to
  644.         open or delete it.
  645.  
  646.  
  647. Function  13h   Delete File Via FCB                                       (FCB)
  648.       Deletes file specified in FCB from current directory
  649. entry   AH      13h
  650.         DS:DX   pointer to address of FCB
  651. return  AL      00h     file deleted
  652.                 0FFh    if file not found or was read-only
  653. note 1) All matching current directory entries are deleted. The global filename
  654.         character "?" is allowed in the filename.
  655.      2) Will not delete files with read-only attribute set
  656.      3) Close open files before deleting them.
  657.      4) Requires Network Access Rights
  658.  
  659.  
  660. Function  14h   Sequential Disk File Read                                 (FCB)
  661.       Reads record sequentially from disk via FCB
  662. entry   AH  14h
  663.         DS:DX   pointer to an opened FCB
  664. return  AL      00h     successful read
  665.                 01h     end of file (no data read)
  666.                 02h     Data Transfer Area too small for record size specified
  667.                         or segment overflow
  668.                 03h     partial record read, EOF found
  669. note 1) The record size is set to the value at offset 0Eh in the FCB.
  670.      2) The record pointed to by the Current Block (offset 0Ch) and the Current
  671.         Record (offset 20h) fields is loaded at the DTA, then the Current Block
  672.         and Current Record fields are incremented.
  673.      3) The record is read into memory at the current DTA address as specified
  674.         by the most recent call to function 1Ah. If the size of the record and
  675.         location of the DTA are such that a segment overflow or wraparound would
  676.         occur, the error return is set to AL=02h
  677.      4) If a partial record is read at the end of the file, it is passed to the
  678.         requested size with zeroes and the error return is set to AL=03h.
  679.  
  680.  
  681. Function  15h   Sequential Disk Write                                     (FCB)
  682.       Writes record specified by FCB sequentially to disk
  683. entry   AH      15h
  684.         DS:DX   pointer to address of FCB
  685. return  AL      00h     successful write
  686.                 01h     diskette full, write canceled
  687.                 02h     disk transfer area (DTA) too small or segment wrap
  688. note 1) The data to write is obtained from the disk transfer area
  689.      2) The record size is set to the value at offset 0Eh in the FCB.
  690.      3) This service cannot write to files set as read-only
  691.      4) The record pointed to by the Current Block (offset 0Ch) and the Current
  692.         Record (offset 20h) fields is loaded at the DTA, then the Current Block
  693.         and Current Record fields are incremented.
  694.      5) If the record size is less than a sector, the data in the DTA is written
  695.         to a buffer; the buffer is written to disk when it contains a full
  696.         sector of data, the file is closed, or a Reset Disk (function 0Dh) is
  697.         issued.
  698.      6) The record is written to disk at the current DTA address as specified
  699.         by the most recent call to function 1Ah. If the size of the record and
  700.         location of the DTA are such that a segment overflow or wraparound would
  701.         occur, the error return is set to AL=02h
  702.  
  703.  
  704. Function  16h   Create A Disk File                                        (FCB)
  705.       Search and open or create directory entry for file
  706. entry   AH      16h
  707.         DS:DX   pointer to an FCB
  708. return  AL      00h     successful creation
  709.                 0FFh    no room in directory
  710. note 1) If a matching directory entry is found, the file is truncated to zero
  711.         bytes.
  712.      2) If there is no matching filename, a filename is created.
  713.      3) This function calls function 0Fh (Open File) after creating or
  714.         truncating a file.
  715.      4) A hidden file can be created by using an extended FCB with the attribute
  716.         byte (offset FCB-1) set to 2.
  717.  
  718.  
  719. Function  17h   Rename File Specified by File Control Block              (FCB)
  720.       Renames file in current directory
  721. entry   AH      17h
  722.         DS:DX   pointer to an FCB (see note 4)
  723. return  AL      00h     successfully renamed
  724.                 0FFh    file not found or filename already exists
  725. note 1) This service cannot rename read-only files
  726.      2) The "?" wildcard may be used.
  727.      3) If the "?" wildcard is used in the second filename, the corresponding
  728.         letters in the filename of the directory entry are not changed.
  729.      4) The FCB must have a drive number, filename, and extension in the usual
  730.         position, and a second filename starting 6 bytes after the first, at
  731.         offset 11h.
  732.      5) The two filenames cannot have the same name.
  733.      6) FCB contains new name starting at byte 17h.
  734.  
  735.  
  736. Function  18h  Internal to DOS
  737.  *   Unknown
  738. entry   AH      18h
  739. return  AL      0
  740.  
  741.  
  742. Function  19h   Get Current Disk Drive
  743.       Return designation of current default disk drive
  744. entry   AH      19h
  745. return  AL      current default drive (0=A, 1=B,etc.)
  746. note    Some other DOS functions use 0 for default, 1=A, 2=B, etc.
  747.  
  748.  
  749. Function  1Ah   Set Disk Transfer Area Address (DTA)
  750.       Sets DTA address to the address specified in DS:DX
  751. entry   AH      1Ah
  752.         DS:DX   pointer to buffer
  753. return  none
  754. note 1) The default DTA is 128 bytes at offset 80h in the PSP. DOS uses the
  755.         DTA for all file I/O.
  756.      2) Registers are unchanged.
  757.      3) No error codes are returned.
  758.      2) Disk transfers cannot wrap around from the end of the segment to the
  759.         beginning or overflow into another segment.
  760.  
  761.  
  762. Function  1Bh   Get Current Drive File Allocation Table Information
  763.       Returns information from the FAT on the current drive
  764. entry   AH      1Bh
  765. exit    AL      number of sectors per allocation unit (cluster)
  766.         DS:BX   address of the current drive's media descriptor byte
  767.         CX      number of bytes per sector
  768.         DX      number of allocation units (clusters) for default drive
  769. note 1) Save DS before calling this function.
  770.      2) This call returned a pointer to the FAT in DOS 1.x. Beginning with
  771.         DOS 2.00, it returns a pointer only to the table's ID byte.
  772.      3) IBM recommends programmers avoid this call and use int 25h instead.
  773.  
  774.  
  775. Function  1Ch   Get File Allocation Table Information for Specific Device
  776.       Returns information on specified drive
  777. entry   AH      1Ch
  778.         DL      drive number (1=A, 2=B, 3=C, etc)
  779. return  AL      number of sectors per allocation unit (cluster)
  780.         DS:BX   address of media descriptor byte for drive in DL
  781.         CX      sector size in bytes
  782.         DX      number of allocation units (clusters)
  783. note 1) DL = 0 for default.
  784.      2) Save DS before calling this function.
  785.      3) Format of media-descriptor byte:
  786.         bits:   0       0   (clear)   not double sided
  787.                         1   (set)     double sided
  788.                 1       0   (clear)   not 8 sector
  789.                         1   (set)     8 sector
  790.                 2       0   (clear)   nonremovable device
  791.                         1   (set)     removable device
  792.                 3-7     always set (1)
  793.      4) This call returned a pointer to the FAT in DOS 1.x. Beginning with
  794.         DOS 2.00, it returns a pointer only to the table's ID byte.
  795.      5) IBM recommends programmers avoid this call and use int 25h instead.
  796.  
  797.  
  798. Function  1Dh   Not Documented by Microsoft
  799.  *    Unknown
  800. entry   AH      1Dh
  801. return  AL      0
  802.  
  803.  
  804. Function  1Eh   Not Documented by Microsoft
  805.  *    Unknown
  806. entry   AH      1Eh
  807. return  AL      0
  808. note    Apparently does nothing
  809.  
  810.  
  811. Function  1Fh Get Default Drive Parameter Block
  812.  *  Same as function call 32h (below), except that the table is accessed from
  813.     the default drive
  814. entry   AH      1Fh
  815.         other registers unknown
  816. return  AL      00h     no error
  817.                 0FFh    error
  818.         DS:BX   points to DOS Disk Parameter Block for default drive.
  819. note 1) Unknown vector returned in ES:BX.
  820.      2) For DOS 2.x and 3.x, this just invokes function 32h (undocumented,
  821.         Read DOS Disk Block) with DL=0
  822.  
  823.  
  824. Function  20h  Unknown
  825.  *   Internal - does nothing?
  826. entry   AH      20h
  827. return  AL      0
  828.  
  829.  
  830. Function  21h  Random Read from File Specified by File Control Block     (FCB)
  831.      Reads one record as specified in the FCB into the current DTA.
  832. entry   AH      21h
  833.         DS:DX   address of the opened FCB
  834. return  AL      00h     successful read operation
  835.                 01h     end of file (EOF), no data read
  836.                 02h     DTA too small for the record size specified
  837.                 03h     end of file (EOF), partial data read
  838. note 1) The current block and current record fields are set to agree with the
  839.         random record field. Then the record addressed by these fields is read
  840.         into memory at the current Disk Transfer Address.
  841.      2) The current file pointers are NOT incremented this function.
  842.      3) If the DTA is larger than the file, the file is padded to the requested
  843.         length with zeroes.
  844.  
  845.  
  846. Function  22h  Random Write to File Specified by FCB                      (FCB)
  847.      Writes one record as specified in the FCB to the current DTA
  848. entry   AH      22h
  849.         DS:DX   address of the opened FCB
  850. return  AL      00h     successful write operation
  851.                 01h     disk full; no data written (write was canceled)
  852.                 02h     DTA too small for the record size specified (write was
  853.                         canceled)
  854. note 1) This service cannot write to read-only files.
  855.      2) The record pointed to by the Current Block (offset 0Ch) and the Current
  856.         Record (offset 20h) fields is loaded at the DTA, then the Current Block
  857.         and Current Record fields are incremented.
  858.      3) If the record size is less than a sector, the data in the DTA is written
  859.         to a buffer; the buffer is written to disk when it contains a full
  860.         sector of data, the file is closed, or a Reset Disk (function 0Dh) is
  861.         issued.
  862.      4) The current file pointers are NOT incremented this function.
  863.      5) The record is written to disk at the current DTA address as specified
  864.         by the most recent call to function 1Ah. If the size of the record and
  865.         location of the DTA are such that a segment overflow or wraparound would
  866.         occur, the error return is set to AL=02h
  867.  
  868.  
  869. Function  23h  Get File Size                                             (FCB)
  870.      Searches current subdirectory for matching file, returns size in FCB
  871. entry   AH      23h
  872.         DS:DX   address of an unopened FCB
  873. return  AL      00h file found
  874.                 0FFh file not found
  875. note 1) Record size field (offset 0Eh) must be set before invoking this function
  876.      2) The disk directory is searched for the matching entry. If a matching
  877.         entry is found, the random record field is set to the number of records
  878.         in the file. If the value of the Record Size field is not an even
  879.         divisor of the file size, the value set in the relative record field is
  880.         rounded up. This gives a returned value larger than the actual file size
  881.      3) This call is used by the APPEND command in DOS 3.2+
  882.  
  883.  
  884. Function  24h  Set Relative Record Field                                  (FCB)
  885.      Set random record field specified by an FCB
  886. entry   AH      24h
  887.         DS:DX   address of an opened FCB
  888. return  Random Record Field of FCB is set to be same as Current Block
  889.         and Current Record.
  890. note 1) You must invoke this function before performing random file access.
  891.      2) The relative record field of FCB (offset 21h) is set to be same as the
  892.         Current Block (offset 0Ch) and Current Record (offset 20h).
  893.      3) No error codes are returned.
  894.      4) The FCB must already be opened.
  895.  
  896.  
  897. Function  25h  Set Interrupt Vector
  898.      Sets the address of the code DOS is to perform each time the specified
  899.      interrupt is invoked.
  900. entry   AH      25h
  901.         AL      int number to reassign the handler to
  902.         DS:DX   address of new interrupt vector
  903. return  none
  904. note 1) Registers are unchanged.
  905.      2) No error codes are returned.
  906.      3) The interrupt vector table for the interrupt number specified in AL
  907.         is set to the address contained in DS:DX. Use function 35h (Get Vector)
  908.         to get the contents of the interrupt vector and save it for later use.
  909.      4) When you use function 25 to set an interrupt vector, DOS 3.2 doesn't
  910.         point the actual interrupt vector to what you requested. Instead, it
  911.         sets the interrupt vector to point to a routine inside DOS, which does
  912.         this:
  913.                 1. Save old stack pointer
  914.                 2. Switch to new stack pointer allocated from DOS's stack pool
  915.                 3. Call your routine
  916.                 4. Restore old stack pointer
  917.         The purpose for this was to avoid possible stack overflows when there
  918.         are a large number of active interrupts. IBM was concerned (this was an
  919.         IBM change, not Microsoft) that on a Token Ring network there would be
  920.         a lot of interrupts going on, and applications that hadn't allocated
  921.         very much stack space would get clobbered.
  922.  
  923.  
  924. Function  26h  Create New Program Segment Prefix (PSP)
  925.      This service copies the current program-segment prefix to a new memory
  926.      location for the creation of a new program or overlay. Once the new PSP is
  927.      in place, a DOS program can read a DOS COM or overlay file into the memory
  928.      location immediately following the new PSP and pass control to it.
  929. entry   AH      26h
  930.         DX      segment number for the new PSP
  931. return  none
  932. note 1) Microsoft recommends you use the newer DOS service 4Bh (EXEC) instead.
  933.      2) The entire 100h area at location 0 in the current PSP is copied into
  934.         location 0 of the new PSP. The memory size information at location 6
  935.         in the new segment is updated and the current termination, ctrl-break,
  936.         and critical error addresses from interrupt vector table entries for
  937.         ints 22h, 23h, and 24 are saved in the new program segment starting at
  938.         0Ah. They are restored from this area when the program terminates.
  939.      3) Current PSP is copied to specified segment
  940.  
  941.  
  942. Function  27h  Random Block Read From File Specified by FCB
  943.      Similar to 21h (Random Read) except allows multiple files to be read.
  944. entry   AH      27h
  945.         CX      number of records to be read
  946.         DS:DX   address of an opened FCB
  947. return  AL      00h     successful read
  948.                 01h     end of file, no data read
  949.                 02h     DTA too small for record size specified (read canceled)
  950.                 03h     end of file
  951.         CX      actual number of records read (includes partial if AL=03h)
  952. note 1) The record size is specified in the FCB. The service updates the Current
  953.         Block (offset 0Ch) and Current Record (offset 20h) fields to the next
  954.         record not read.
  955.      2) If CX contained 0 on entry, this is a NOP.
  956.      3) If the DTA is larger than the file, the file is padded to the requested
  957.         length with zeroes.
  958.      4) This function assumes that the FCB record size field (0Eh) is correctly
  959.         set. If not set by the user, the default is 128 bytes.
  960.      5) The record is written to disk at the current DTA address as specified
  961.         by the most recent call to function 1Ah. If the size of the record and
  962.         location of the DTA are such that a segment overflow or wraparound would
  963.         occur, the error return is set to AL=02h
  964.  
  965.  
  966. Function  28h  Random Block Write to File Specified in FCB
  967.      Similar to 27h (Random Write) except allows multiple files to be read.
  968. entry   AH      28h
  969.         CX      number of records to write
  970.         DS:DX   address of an opened FCB
  971. return  AL      00h     successful write
  972.                 01h     disk full, no data written
  973.                 02h     DTA too small for record size specified (write canceled)
  974.         CX      number of records written
  975. note 1) The record size is specified in the FCB.
  976.      2) This service allocates disk clusters as required.
  977.      3) This function assumes that the FCB Record Size field (offset 0Eh) is
  978.         correctly set. If not set by the user, the default is 128 bytes.
  979.      4) The record size is specified in the FCB. The service updates the Current
  980.         Block (offset 0Ch) and Current Record (offset 20h) fields to the next
  981.         record not read.
  982.      5) The record is written to disk at the current DTA address as specified
  983.         by the most recent call to function 1Ah. If the size of the record and
  984.         location of the DTA are such that a segment overflow or wraparound would
  985.         occur, the error return is set to AL=02h
  986.      6) If called with CX=0, no records are written, but the FCB's File Size
  987.         entry (offset 1Ch) is set to the size specified by the FCB's Relative
  988.         Record field (offset 21h).
  989.  
  990.  
  991. Function  29h  Parse the Command Line for Filename
  992.      Parses a text string into the fields of a File Control Block
  993. entry   AH      29h
  994.         DS:SI   pointer to string to parse
  995.         ES:DI   pointer to memory buffer to fill with unopened FCB
  996.         AL      bit mask to control parsing
  997.                 bit 0 = 0: parsing stops if file seperator found
  998.                         1: causes service to scan past leading chars such as
  999.                            blanks. Otherwise assumes the filename begins in
  1000.                            the first byte
  1001.                     1 = 0: drive number in FCB set to default (0) if string
  1002.                            contains no drive number
  1003.                         1: drive number in FCB not changed
  1004.                     2 = 0: filename in FCB set to 8 blanks if no filename in
  1005.                            string
  1006.                         1: filename in FCB not changed if string does not
  1007.                            contain a filename
  1008.                     3 = 0: extension in FCB set to 3 blanks if no extension in
  1009.                            string
  1010.                         1: extension left unchanged
  1011.                     4-7    must be zero
  1012. return  AL      00h     no wildcards in name or extension
  1013.                 01h     wildcards appeared in name or extension
  1014.                 0FFh    invalid drive specifier
  1015.         DS:SI   pointer to the first byte after the parsed string
  1016.         ES:DI   pointer to a buffer filled with the unopened FCB
  1017. note 1) If the * wildcard characters are found in the command line, this service
  1018.         will replace all subsequent chars in the FCB with question marks.
  1019.      2) This service uses the characters as filename separators
  1020.         DOS 1       : ; . , + / [ ] = " TAB SPACE
  1021.         DOS 2,3     : ; . , + = TAB SPACE
  1022.      3) This service uses the characters
  1023.         : ; . , + < > | / \ [ ] = " TAB SPACE
  1024.         or any control characters as valid filename separators
  1025.      4) A filename cannot contain a filename terminator. If one is encountered,
  1026.         all processing stops. The handle functions will allow use of some of
  1027.         these characters.
  1028.      5) If no valid filename was found on the command line, ES:DI +1 points
  1029.         to a blank (ASCII 32).
  1030.      6) This function cannot be used with filespecs which include a path
  1031.      7) Parsing is in the form D:FILENAME.EXT. If one is found, a corresponding
  1032.         unopened FCB is built at ES:DI
  1033.  
  1034.  
  1035. Function  2Ah  Get Date
  1036.      Returns day of the week, year, month, and date
  1037. entry   AH      2Ah
  1038. return  CX      year    (1980-2099)
  1039.         DH      month   (1-12)
  1040.         DL      day     (1-31)
  1041.         AL      weekday 00h     Sunday
  1042.                         01h     Monday
  1043.                         02h     Tuesday
  1044.                         03h     Wednesday
  1045.                         04h     Thursday
  1046.                         05h     Friday
  1047.                         06h     Saturday
  1048. note 1) Date is adjusted automatically if clock rolls over to the next day,
  1049.         and takes leap years and number of days in each month into account.
  1050.      2) Although DOS cannot set an invalid date, it can read one, such as
  1051.         1/32/80, etc.
  1052.      3) DesQview also accepts CX = 4445h and DX = 5351h, i.e. 'DESQ' as valid
  1053.      4) DOS will accept CH=0 (midnight) as a valid time, but if a file's time
  1054.         is set to exactly midnight the time will not be displayed by the DIR
  1055.         command.
  1056.  
  1057.  
  1058. Function  2Bh  Set Date
  1059.      set current system date
  1060. entry   AH      2Bh
  1061.         CX      year    (1980-2099)
  1062.         DH      month   (1-12)
  1063.         DL      day     (1-31)
  1064. return  AL      00h     no error (valid date)
  1065.                 0FFh    invalid date specified
  1066. note 1) On entry, CX:DX must have a valid date in the same format as returned
  1067.         by function call 2Ah
  1068.      2) DOS 3.3 also sets CMOS clock
  1069.  
  1070.  
  1071. Function  2Ch  Get Time
  1072.      Get current system time from CLOCK$ driver
  1073. entry   AH      2Ch
  1074. return  CH      hours   (0-23)
  1075.         CL      minutes (0-59)
  1076.         DH      seconds (0-59)
  1077.         DL      hundredths of a second (0-99)
  1078. note 1) Time is updated every 5/100 second.
  1079.      2) The date and time are in binary format
  1080.  
  1081.  
  1082. Function  2Dh  Set Time
  1083.      Sets current system time
  1084. entry   AH      2Dh
  1085.         CH      hours   (0-23)
  1086.         CL      minutes (0-59)
  1087.         DH      seconds (0-59)
  1088.         DL      hundredths of seconds (0-99)
  1089. return  AL      00h     if no error
  1090.                 0FFh    if bad value sent to routine
  1091. note 1) DOS 3.3 also sets CMOS clock
  1092.      2) CX and DX must contain a valid time in binary
  1093.  
  1094.  
  1095. Function  2Eh  Set/Reset Verify Switch
  1096.      Set verify flag
  1097. entry   AH      2Eh
  1098.         AL      00      to turn verify off (default)
  1099.                 01      to turn verify on
  1100. return  none
  1101. note 1) This is the call invoked by the DOS VERIFY command
  1102.      2) Setting of the verify switch can be obtained by calling call 54h
  1103.      3) This call is not supported on network drives
  1104.      4) DOS checks this flag each time it accesses a disk
  1105.  
  1106.  
  1107. Function  2Fh  Get Disk Transfer Address (DTA)
  1108.      Returns current disk transfer address used by all DOS read/write operations
  1109. entry   AH      2Fh
  1110. return  ES:BX   address of DTA
  1111. note 1) The DTA is set by function call 1Ah
  1112.      2) Default DTA address is a 128 byte buffer at offset 80h in that program's
  1113.         Program Segment Prefix
  1114.  
  1115.  
  1116. Function  30h  Get DOS Version Number
  1117.      Return DOS version and/or user number
  1118. entry   AH      30h
  1119. return  AH      minor version number  (i.e., DOS 2.10 returns AX = 0A02h)
  1120.         AL      major version number
  1121.         BH      OEM ID number
  1122.                 00h     IBM
  1123.                 16h     DEC    (others not known)
  1124.         BL:CX   24-bit user serial number
  1125. note 1) If AL returns a major version number of zero, the DOS version is
  1126.         below 1.28 for MSDOS and below 2.00 for PCDOS.
  1127.      2) IBM PC-DOS always returns 0000h in BX and CX.
  1128.      3) OS/2 v1.0 Compatibility Box returns a value of 10 for major version.
  1129.      4) Due to the OS/2 return and the fact that some European versions of DOS
  1130.         carry higher version numbers than IBM's DOS, utilities which check
  1131.         for a DOS version should not abort if a higher version than required
  1132.         is found unless some specific problems are known.
  1133.  
  1134.  
  1135. Function  31h  Terminate Process and Stay Resident
  1136.      KEEP, or TSR
  1137. entry   AH      31h
  1138.  
  1139.         AL      exit code
  1140.         DX      program memory requirement in 16 byte paragraphs
  1141. return  AX      return code (retrieveable by function 4Dh)
  1142. note 1) Files opened by the application are not closed when this call is made
  1143.      2) Memory can be used more efficiently if the block containing the copy of
  1144.         the DOS environment is deallocated before terminating. This can be done
  1145.         by loading ES with the segment contained in 2Ch of the PSP and issuing
  1146.         function call 49h (Free Allocated Memory).
  1147.      3) Unlike int 27h, more than 64k may be made resident with this call
  1148.  
  1149.  
  1150. Function  32h  Read DOS Disk Block
  1151.  *   Retrieve the pointer to the drive parameter block for a drive
  1152. entry   AH      32h
  1153.         DL      drive (0=default, 1=A:, etc.).
  1154. return  AL      00h     if drive is valid
  1155.                 0FFh    if drive is not valid
  1156.         DS:BX   pointer to DOS Drive Parameter Table. Format of block:
  1157.                 Bytes   Type        Value
  1158.                 00h     byte    Drive: 0=A:, 1=B:, etc.
  1159.                 01h     byte    Unit within drive (0, 1, 2, etc.)
  1160.                 02h-03h word    Bytes per sector
  1161.                 04h     byte    Sectors per cluster - 1
  1162.                 05h     byte    Cluster to sector shift (i.e., how far to shift-
  1163.                                 left the bytes/sector to get bytes/cluster)
  1164.                 06h-07h word    Number of reserved (boot) sectors
  1165.                 08h     byte    Number of FATs
  1166.                 09h-0Ah word    Number of root directory entries
  1167.                 0Bh-0Ch word    Sector # of 1st data. Should be same as # of
  1168.                                 sectors/track.
  1169.                 0Dh-0Eh word    # of clusters + 1 (=last cluster #)
  1170.                 0Fh     byte    Sectors for FAT
  1171.                 10h-11h word    First sector of root directory
  1172.                 12h-15h dword   Address of device driver header for this drive
  1173.                 16h     byte    Media Descriptor Byte for this drive
  1174.                 17h     byte    0FFh indicates block must be rebuilt
  1175.                                 (DOS 3.x) 00h indicates block device has
  1176.                                 been accessed
  1177.                 18h-1Bh dword   address of next DOS Disk Block (0FFFFh means
  1178.                                 last in chain)
  1179.                 22h     byte    Current Working Directory (2.0 only) (64 bytes)
  1180. note 1) Use [BX+0D] to find no. of clusters (>1000H, 16-bit FAT; if not, 12-bit
  1181.         (exact dividing line is probably a little below 1000h to allow for
  1182.         bad sectors, EOF markers, etc.)
  1183.      2) Short article by C.Petzold, PC Magazine  Vol.5,no.8, and the article
  1184.         "Finding Disk Parameters" in the May 1986 issue of PC Tech Journal.
  1185.      3) This call is mostly supported in OS/2 1.0's DOS Compatibility Box. The
  1186.         dword at 12h will not return the address of the next device driver when
  1187.         in the Compatibility Box.
  1188.      4) used by CHKDSK
  1189.  
  1190.  
  1191. Function  33h  Control-Break Check
  1192.      Get or set control-break checking at CON
  1193. entry   AH      33h
  1194.         AL      00h     to test for break checking
  1195.                 01h     to set break checking
  1196.                         DL      00h     to disable break checking
  1197.                                 01h     to enable break checking
  1198.                 02h     internal, called by PRINT.COM (DOS 3.1)
  1199.                 03h     unknown
  1200.                 04h     unknown
  1201.                 05h     boot drive (DOS 4.0+)
  1202. return  DL      00h     if break=off
  1203.                 01h     if break=on
  1204.                 (if AL=05h) boot drive, A=1, B=2, etc)
  1205.         AL      0FFh    error
  1206.  
  1207.  
  1208. Function  34h  Return INDOS Flag
  1209.  *   Returns ES:BX pointing to Critical Section Flag, byte indicating whether
  1210.      it is safe to interrupt DOS.
  1211. entry   AH      34h
  1212. return  ES:BX   points to DOS "critical section flag"
  1213. note 1) If byte is 0, it is safe to interrupt DOS. This was mentioned in some
  1214.         documentation by Microsoft on a TSR standard, and PC Magazine reports
  1215.         it functions reliably under DOS versions 2.0 through 3.3. Chris
  1216.         Dunford (of CED fame) and a number of anonymous messages on the BBSs
  1217.         indicate it may not be totally reliable.
  1218.      2) The byte at ES:BX+1 is used by the Print program for this same purpose,
  1219.         so it's probably safer to check the WORD at ES:BX.
  1220.      3) Reportedly, examination of DOS 2.10 code in this area indicates that the
  1221.         byte immediately following this "critical section flag" must be 00h to
  1222.         permit the PRINT.COM interrupt to be called. For DOS 3.0 and 3.1 (except
  1223.         Compaq DOS 3.0), the byte before the "critical section flag" must be
  1224.         zero; for Compaq DOS 3.0, the byte 01AAh before it must be zero.
  1225.      4) In DOS 3.10 this reportedly changed to word value, with preceding byte.
  1226.      5) This call is supported in OS/2 1.0's DOS Compatibility Box
  1227.      6) Gordon Letwin of Microsoft discussed this call on ARPAnet in 1984. He
  1228.         stated:
  1229.         a) this is not supported under any version of the DOS
  1230.         b) it usually works under DOS 2, but there may be circumstances
  1231.            when it doesn't (general disclaimer, don't know of a specific
  1232.            circumstance)
  1233.         c) it will usually not work under DOS 3 and DOS 3.1; the DOS is
  1234.            considerably restructured and this flag takes on additional
  1235.            meanings and uses
  1236.         d) it will fail catastrophically under DOS 4.0 and forward.
  1237.            Obviously this information is incorrect since the call works fine
  1238.            through DOS 3.3. Microsoft glasnost?
  1239.  
  1240.  
  1241. Function  35h  Get Vector
  1242.      Get interrupt vector
  1243. entry   AH      35h
  1244.         AL      interrupt number (hexadecimal)
  1245. return  ES:BX   address of interrupt vector
  1246. note    Use function call 25h to set the interrupt vectors
  1247.  
  1248.  
  1249. Function  36h  Get Disk Free Space
  1250.      get information on specified drive
  1251. entry   AH      36h
  1252.         DL      drive number (0=default, 1=A:, 2=B:, etc)
  1253. return  AX      number of sectors per cluster
  1254.                 0FFFFh means drive specified in DL is invalid
  1255.         BX      number of availible clusters
  1256.         CX      bytes per sector
  1257.         DX      clusters per drive
  1258. note 1) Mult AX * CX * BX for free space on disk
  1259.      2) Mult AX * CX * DX for total disk space
  1260.      3) Function 36h returns an incorrect value after an ASSIGN command. Prior
  1261.         to ASSIGN, the DX register contains 0943h on return, which is the free
  1262.         space in clusters on the HC diskette. After ASSIGN, even with no
  1263.         parameters, 0901h is returned in the DX register; this is an incorrect
  1264.         value. Similar results occur with DD diskettes on a PC-XT or a PC-AT.
  1265.         This occurs only when the disk is not the default drive. Results are as
  1266.         expected when the drive is the default drive. Therefore, the
  1267.         circumvention is to make the desired drive the default drive prior to
  1268.         issuing this function call.
  1269.      4) Int 21h, function call 36h returns an incorrect value after an ASSIGN
  1270.         command. Prior to ASSIGN, the DX register contains 0943h on return,
  1271.         which is the free space in clusters on the HC diskette. After ASSIGN,
  1272.         even with no parameters, 0901h is returned in the DX register; this is
  1273.         an incorrect value. Similar results occur with DD diskettes on a PC-XT
  1274.         or a PC-AT. This occurs only when the disk is not the default drive.
  1275.         Results are as expected when the drive is the default drive. Therefore,
  1276.         the circumvention is to make the desired drive the default drive prior
  1277.         to issuing this function call.
  1278.      5) This function supercedes functions 1Bh and 1Ch.
  1279.  
  1280.  
  1281. Function  37h  SWITCHAR / AVAILDEV
  1282.  *   Get/set option marking character (is usually "/"), and device type
  1283. entry   AH      37h
  1284.         AL      00h     read switch character (returns current character in DL)
  1285.                 01h     set character in DL as new switch character
  1286.       (DOS 2.x) 02h     read device availability (as set by function AL=3) into
  1287.                         DL. A 0 means devices that devices must be accessed in
  1288.                         file I/O calls by /dev/device. A non-zero value means
  1289.                         that devices are accessible at every level of the
  1290.                         directory tree (e.g., PRN is the printer and not a file
  1291.                         PRN).
  1292.                         AL=2 to return flag in DL, AL=3 to set from DL (0 = set,
  1293.                         1 = not set).
  1294.       (DOS 2.x) 03h     get device availability, where:
  1295.         DL      00h     means /dev/ must precede device names
  1296.                 01h     means /dev/ need not precede device names
  1297. return  DL      switch character (if AL=0 or 1)
  1298.                 device availability flag (if AL=2 or 3)
  1299.         AL      0FFh    the value in AL was not in the range 0-3.
  1300. note 1) Functions 2 & 3 appear not to be implemented for DOS 3.x.
  1301.      2) It is documented on page 4.324 of the MS-DOS (version 2) Programmer's
  1302.         Utility Pack (Microsoft - published by Zenith).
  1303.      3) Works on all versions of IBM PC-DOS from 2.0 through 3.3.1.
  1304.      4) The SWITCHAR is the character used for "switches" in DOS command
  1305.         arguments (defaults to '/', as in "DIR/P"). '-' is popular to make a
  1306.         system look more like UNIX; if the SWITCHAR is anything other than '/',
  1307.         then '/' may be used instead of '\' for pathnames
  1308.      5) Ignored by XCOPY, PKARC, LIST
  1309.      6) SWITCHAR may not be set to any character used in a filename
  1310.      7) In DOS 3.x you can still read the "AVAILDEV" byte with subfunction 02h
  1311.         but it always returns 0FFh even if you try to change it to 0 with
  1312.         subfunction 03h.
  1313.      8) AVAILDEV=0 means that devices must be referenced in an imaginary
  1314.         subdirectory "\dev" (similar to UNIX's /dev/*); a filename "PRN.DAT"
  1315.         can be created on disk and manipulated like any other. If AVAILDEV != 0
  1316.         then device names are recognized anywhere (this is the default):
  1317.         "PRN.DAT" is synonymous with "PRN:".
  1318.      9) These functions reportedly are not supported in the same fashion in
  1319.         various implementations of DOS.
  1320.     10) used by DOS 3.3 CHKDSK, BASIC, DEBUG
  1321.  
  1322.  
  1323. Function  38h   Return Country Dependent Information
  1324.                 (PCDOS 2.0, 2.1, MSDOS 2.00 only)
  1325. entry   AH      38h
  1326.         AL      function code  (must be 0 in DOS 2.x)
  1327.         DS:DX   pointer to 32 byte memory buffer for returned information
  1328. return  CF      set on error
  1329.                 AX      error code (02h)
  1330.         BX      country code
  1331.         DS:DX   pointer to buffer filled with country information:
  1332.                 bytes 0,1       date/time format
  1333.                                 0       USA standard       H:M:S   M/D/Y
  1334.                                 1       European standard  H:M:S   D/M/Y
  1335.                                 2       Japanese standard  H:M:S   D:M:Y
  1336.                 byte2   ASCIIZ string currency symbol
  1337.                 byte3   zeroes
  1338.                 byte4   ASCIIZ string thousands separator
  1339.                 byte5   zeroes
  1340.                 byte6   ASCIIZ string decimal separator
  1341.                 byte7   zeroes
  1342.                 bytes 8,1Fh  24 bytes   reserved
  1343.  
  1344.  
  1345. Function  38h   Get Country Dependent Information
  1346.                 (PCDOS 3.x+, MSDOS 2.01+)
  1347. entry   AH      38h
  1348.         AL      function code
  1349.                 00h     to get current country information
  1350.                 01h-0FEh country code to get information for, for countries
  1351.                         with codes less than 255
  1352.                 0FFh    to get country information for countries with a code
  1353.                         greater than 255
  1354.                         BX      16 bit country code if AL=0FFh
  1355.         DS:DX   pointer to the memory buffer where the data will be returned
  1356.                 DX      0FFFFh if setting country code rather than getting info
  1357. return  CF      0 (clear) function completed
  1358.                 1 (set) error
  1359.                    AX   error code
  1360.                         02h     invalid country code (no table for it)
  1361.         (if DX <> 0FFFFh)
  1362.         BX      country code (usually international telephone code)
  1363.         DS:DX   pointer to country data buffer
  1364.           bytes 0,1     date/time format
  1365.                         0       USA standard       H:M:S   M/D/Y
  1366.                         1       European standard  H:M:S   D/M/Y
  1367.                         2       Japanese standard  H:M:S   D:M:Y
  1368.           bytes 2-6     currency symbol null terminated
  1369.           byte  07h     thousands separator null terminated
  1370.           byte  08h     zeroes
  1371.           byte  09h     decimal separator null terminated
  1372.           byte  0Ah     zeroes
  1373.           byte  0Bh     date separator null terminated
  1374.           byte  0Ch     zeroes
  1375.           byte  0Dh     time separator null terminated
  1376.           byte  0Eh     zeroes
  1377.           byte  0Fh     bit field currency format
  1378.                         bit 0 = 0  if currency symbol precedes the value
  1379.                                 1  if currency symbol is after the value
  1380.                         bit 1 = 0  no spaces between value and currency symbol
  1381.                                 1  one space between value and currency symbol
  1382.                         bit 2 = 1  set if currency symbol replaces decimal pt
  1383.                         bits 3-7   not defined by Microsoft
  1384.           byte  10h     number of significant decimal digits in currency
  1385.                         (number of places to right of decimal point)
  1386.           byte  11h     time format
  1387.                         bit 0 = 0       12 hour clock
  1388.                                 1       24 hour clock
  1389.                         bits 1-7 unknown, probably not used
  1390.           bytes 12h-15h address of case map routine (FAR CALL, AL = char)
  1391.                         entry   AL  ASCII code of character to be converted to
  1392.                                     uppercase
  1393.                         return  AL  ASCII code of the uppercase input character
  1394.           byte  16h     data-list separator character
  1395.           byte  17h     zeroes
  1396.           bytes 18h-21h 5 words reserved
  1397. note 1) When an alternate keyboard handler is invoked, the keyboard routine is
  1398.         loaded into user memory starting at the lowest portion of availible
  1399.         user memory. The BIOS interrupt vector that services the keyboard is
  1400.         redirected to the memory area where the new routine resides. Each new
  1401.         routine takes up about 1.6K of memory and has lookup tables that return
  1402.         values unique to each language. (KEYBxx in the DOS book)
  1403.          Once the keyboard interrupt vector is changed by the DOS keyboard
  1404.         routine, the new routine services all calls unless the system is
  1405.         returned to the US format by the ctrl-alt-F1 keystroke combination. This
  1406.         does not change the interrupt vector back to the BIOS location; it
  1407.         merely passes the table lookup to the ROM locations.
  1408.      2) Ctrl-Alt-F1 will only change systems with US ROMS to the US layout.
  1409.         Some systems are delivered with non-US keyboard handler routines in ROM
  1410.      3) Case mapping call: the segment/offset of a FAR procedure that performs
  1411.         country-specific lower-to-upper case mapping on ASCII characters 80h to
  1412.         0FFh. It is called with the character to be mapped in AL. If there is
  1413.         an uppercase code for the letter, it is returned in AL, if there is no
  1414.         code or the function was called with a value of less than 80h AL is
  1415.         returned unchanged.
  1416.      4) This call is fully implemented in MS-DOS version 2.01 and higher. It
  1417.         is in version 2.00 but not fully implemented (according to Microsoft)
  1418.  
  1419.  
  1420. Function  38h   Set Country Dependent Information
  1421. entry   AH      38h
  1422.         AL      code    country code to set information for, for countries
  1423.                         with codes less than 255
  1424.                 0FFh    to set country information for countries with a code
  1425.                         greater than 255
  1426.         BX      16 bit country code if AL=0FFh
  1427.         DX      0FFFFh
  1428. return  CF      clear   successful
  1429.                 set     if error
  1430.                         AX      error code (02h)
  1431.  
  1432.  
  1433. Function  39h   Create Subdirectory (MKDIR)
  1434.                 Makes a subdirectory along the indicated path
  1435. entry   AH      39h
  1436.         DS:DX   address of ASCIIZ pathname string
  1437. return  flag CF 0       successful
  1438.                 1       error
  1439.                         AX      error code if any  (3, 5)
  1440. note 1) The ASCIIZ string may contain drive and subdirectory.
  1441.      2) Drive may be any valid drive (not nescessarily current drive)
  1442.      3) The pathname cannot exceed 64 characters
  1443.  
  1444.  
  1445. Function  3Ah   Remove Subdirectory  (RMDIR)
  1446. entry   AH      3Ah
  1447.         DS:DX   address of ASCIIZ pathname string
  1448. return  CF      clear     successful
  1449.                 set       AX      error code if any  (3, 5, 16)
  1450. note 1) The ASCIIZ string may contain drive and subdirectory.
  1451.      2) Drive may be any valid drive (not nescessarily current drive)
  1452.      3) The pathname cannot exceed 64 characters
  1453.  
  1454.  
  1455. Function  3Bh   Change Current Directory  (CHDIR)
  1456. entry   AH      3Bh
  1457.         DS:DX   address of ASCIIZ string
  1458. return  flag CF 0       successful
  1459.                 1       error
  1460.         AX      error code if any (3)
  1461. note 1) The pathname cannot exceed 64 characters
  1462.      2) The ASCIIZ string may contain drive and subdirectory.
  1463.      3) Drive may be any valid drive (not nescessarily current drive)
  1464.  
  1465.  
  1466. Function  3Ch   Create A File (CREAT)
  1467.                 Create a file with handle
  1468. entry   AH      3Ch
  1469.         CX      attributes for file
  1470.                 00h     normal
  1471.                 01h     read only
  1472.                 02h     hidden
  1473.                 03h     system
  1474.         DS:DX   address of ASCIIZ filename string
  1475. return  flag CF 0       successful creation
  1476.                 1       error
  1477.         AX      16 bit file handle
  1478.                 or error code  (3, 4, 5)
  1479. note 1) The ASCIIZ string may contain drive and subdirectory.
  1480.      2) Drive may be any valid drive (not nescessarily current drive)
  1481.      3) If the volume label or subdirectory bits are set in CX, they are ignored
  1482.      4) The file is opened in read/write mode
  1483.      5) If the file does not exist, it is created. If one of the same name
  1484.         exists, it is truncated to a length of 0.
  1485.      6) Good practice is to attempt to open a file with fn 3Dh and jump to an
  1486.         error routine if successful, create file if 3Dh fails. That way an
  1487.         existing file will not be truncated and overwritten.
  1488.  
  1489.  
  1490. Function  3Dh   Open A File
  1491.                 Open disk file with handle
  1492. entry   AH      3Dh
  1493.         AL      access code byte
  1494. (DOS 2.x)       bits 0-2  file attribute
  1495.                 000     read only
  1496.                 001     write only
  1497.                 010     read/write
  1498.                 bits 3-7 should be set to zero
  1499. (DOS 3.x)       bits 0-2  file attribute
  1500.                 000     read only
  1501.                 001     write only
  1502.                 010     read/write
  1503.                 bit 3   reserved
  1504.                 0       should be set to zero
  1505.                 bits 4-6 sharing mode (network)
  1506.                 000     compatibility mode (the way FCBs open files)
  1507.                 001     read/write access denied (exclusive)
  1508.                 010     write access denied
  1509.                 011     read access denied
  1510.                 100     full access permitted
  1511.                 bit 7   inheritance flag
  1512.                 0       file inherited by child process
  1513.                 1       file private to child process
  1514.         DS:DX   address of ASCIIZ pathname string
  1515. return  flag CF set on error
  1516.                 AX      error code
  1517.                 1       error
  1518.         AX      16 bit file handle
  1519.                 or error code (1, 2, 4, 5, 0Ch)
  1520. note 1) Opens any normal, system, or hidden file
  1521.      2) Files that end in a colon are not opened
  1522.      3) The rear/write pointer is set at the first byte of the file and the
  1523.         record size of the file is 1 byte (the read/write pointer can be changed
  1524.         through function call 42h). The returned file handle must be used for
  1525.         all subsequent input and output to the file.
  1526.      4) If the file handle was inherited from a parent process or was
  1527.         duplicated by DUP or FORCEDUP, all sharing and access restrictions are
  1528.         also inherited.
  1529.      5) A file sharing error (error 1) causes an int 24h to execute with an
  1530.         error code of 2
  1531.  
  1532.  
  1533. Function  3Eh   Close A File Handle
  1534.                 Close a file and release handle for reuse
  1535. entry   AH      3Eh
  1536.         BX      file handle
  1537. return  flag CF 0       successful close
  1538.                 1       error
  1539.         AX      error code if error (6)
  1540. note 1) When executed, the file is closed, the directory is updated, and all
  1541.         buffers for that file are flushed. If the file was changed, the time
  1542.         and date stamps are changed to current
  1543.      2) If called with the handle 00000, it will close STDIN (normally the
  1544.         keyboard).
  1545.  
  1546.  
  1547. Function  3Fh   Read From A File Or Device
  1548.                 Read from file with handle
  1549. entry   AH      3Fh
  1550.         BX      file handle
  1551.         CX      number of bytes to read
  1552.         DS:DX   address of buffer
  1553. return  flag CF 0       successful read
  1554.                 1       error
  1555.         AX      0       pointer was already at end of file
  1556.                         or number of bytes read
  1557.                         or error code (5, 6)
  1558. note 1) This function attempts to transfer the number of bytes specified in CX
  1559.         to a buffer location. It is not guaranteed that all bytes will be read.
  1560.         If AX < CX a partial record was read.
  1561.      2) If performed from STDIN (file handle 0000), the input can be redirected
  1562.      3) If used to read the keyboard, it will only read to the first CR
  1563.      4) The file pointer is incremented to the last byte read.
  1564.  
  1565.  
  1566. Function  40h   Write To A File Or Device
  1567.                 Write to file with handle
  1568. entry   AH      40h
  1569.         BX      file handle
  1570.         CX      number of bytes to write
  1571.         DS:DX   address of buffer
  1572. return  flag CF 0       successful write
  1573.                 1       error
  1574.         AX      number of bytes written
  1575.                 or error code  (5, 6)
  1576. note 1) This call attempts to transfer the number of bytes indicated in CX
  1577.         from a buffer to a file. If CX and AX do not match after the write,
  1578.         an error has taken place; however no error code will be returned for
  1579.         this problem. This is usually caused by a full disk.
  1580.      2) If the write is performed to STDOUT (handle 0001), it may be redirected
  1581.      3) To truncate the file at the current position of the file pointer, set
  1582.         the number of bytes in CX to zero before calling int 21h. The pointer
  1583.         can be moved to any desired position with function 42h.
  1584.      4) This function will not write to a file or device marked read-only.
  1585.      5) May also be used to display strings to CON instead of fn 09h. This
  1586.         function will write CX bytes and stop; fn 09h will continue to write
  1587.         until a $ character is found.
  1588.      6) This is the call that DOS actually uses to write to the screen in DOS
  1589.         2.x and above.
  1590.  
  1591.  
  1592. Function  41h   Delete A File From A Specified Subdirectory  (UNLINK)
  1593. entry   AH      41h
  1594.         DS:DX   pointer to ASCIIZ filespec to delete
  1595. return  CF      0       successful
  1596.                 1       error
  1597.                 AX      error code if any  (2, 5)
  1598. note 1) This function will not work on a file marked read-only
  1599.      2) Wildcards are not accepted
  1600.  
  1601.  
  1602. Function  42h   Move a File Read/Write Pointer  (LSEEK)
  1603. entry   AH      42h
  1604.         AL      method code
  1605.                 00h     offset from beginning of file
  1606.                 01h     offset from present location
  1607.                 02h     offset from end of file
  1608.         BX      file handle
  1609.         CX      most significant half of offset
  1610.         DX      least significant half of offset
  1611. return  AX      low offset of new file pointer
  1612.         DX      high offset of new file pointer
  1613.         CF      0       successful move
  1614.                 1       error
  1615.                 AX      error code (1, 6)
  1616. note 1) If pointer is at end of file, reflects file size in bytes.
  1617.      2) The value in DX:AX is the absolute 32 bit byte offset from the beginning
  1618.         of the file
  1619.  
  1620.  
  1621. Function   43h  Get/Set file attributes  (CHMOD)
  1622. entry   AH      43h
  1623.         AL      00h     get file attributes
  1624.                 01h     set file attributes
  1625.                 CX      file attributes to set
  1626.                     bit 0       read only
  1627.                         1       hidden file
  1628.                         2       system file
  1629.                         3       volume label
  1630.                         4       subdirectory
  1631.                         5       written since backup
  1632.         DS:DX   pointer to full ASCIIZ file name
  1633. return  CF      set if error
  1634.         AX      error code  (1, 2, 3, 5)
  1635.         CX      file attributes on get
  1636.                 attributes:
  1637.                 01h     read only
  1638.                 02h     hidden
  1639.                 04h     system
  1640.                 0FFh    archive
  1641. note 1) This call will not change the volume label or directory bits
  1642.  
  1643.  
  1644. Function  44h   I/O Control for Devices (IOCTL)
  1645.                 Get or Set Device Information
  1646. entry   AH      44h
  1647.         AL      00h     Get Device Information (from DX)
  1648.                         BX      file or device handle
  1649.                         return  DX      device info
  1650.                                         If bit 7 set: (character device)
  1651.                                            bit 0: console input device
  1652.                                                1: console output device
  1653.                                                2: NUL device
  1654.                                                3: CLOCK$ device
  1655.                                                4: device is special
  1656.                                                5: binary (raw) mode
  1657.                                                6: not EOF
  1658.                                               12: network device (DOS 3.x)
  1659.                                               14: can process IOCTL control
  1660.                                                   strings (func 2-5)
  1661.                                         If bit 7 clear: (file)
  1662.                                            bits 0-5: block device number
  1663.                                                 6: file has not been written
  1664.                                                12: Network device (DOS 3.x)
  1665.                                                15: file is remote (DOS 3.x)
  1666.                 01h     Set Device Information (DH must be zero for this call)
  1667.                         DX bits:
  1668.                         0    1  console input device
  1669.                         1    1  console output device
  1670.                         2    1  null device
  1671.                         3    1  clock device
  1672.                         4    1  reserved
  1673.                         5    0  binary mode - don't check for control chars
  1674.                              1  cooked mode - check for control chars
  1675.                         6    0  EOF - End Of File on input
  1676.                         7       device is character device if set, if not, EOF
  1677.                                 is 0 if channel has been written, bits 0-5 are
  1678.                                 block device number
  1679.                         12      network device
  1680.                         14   1  can process control strings (AL 2-5, can only be
  1681.                                 read, cannot be set)
  1682.                         15   n  reserved
  1683.                 02h     Read CX bytes to device in DS:DX from BX control chan
  1684.                 03h     Write Device Control String
  1685.                         BX      device handle
  1686.                         CX      number of bytes to write
  1687.                         DS:DX   pointer to buffer
  1688.                         return  AX      number of bytes written
  1689.                 04h     Read From Block Device (drive number in BL)
  1690.                         BL      drive number (0=default)
  1691.                         CX      number of bytes to read
  1692.                         DS:DX   pointer to buffer
  1693.                         return  AX      number of bytes read
  1694.                 05h     Write to Block Device  (drive number in BL)
  1695.                         AX      number of bytes transfered
  1696.                 06h     Get Input Handle Status
  1697.                         BX      file or device handle
  1698.                         return  AL      0FFh    device ready
  1699.                                         00h     device not ready
  1700.                 07h     Get Output Handle Status
  1701.                         return  AL      00h     not ready
  1702.                                         0FFh    ready
  1703.                          note: for DOS 2.x, files are always ready for output
  1704.                 08h     Removable Media Bit (DOS 3.x+)
  1705.                         return  AX      00h     device is removable
  1706.                                         01h     device is nonremovable
  1707.                                         0Fh     invalid drive specification
  1708.                 09h     Test whether Local or Network Device in BL (DOS 3.x+)
  1709.                         BL      drive number (0=default)
  1710.                         return  DX      attribute word, bit 12 set if device is
  1711.                                         remote
  1712.                 0Ah     Is Handle in BX Local or Remote? (DOS 3.x+)
  1713.                         BX     file handle
  1714.                         return DX (attribute word) bit 15 set if file is remote
  1715.                 0Bh     Change Sharing Retry Count to DX (default=3), (DOS 3.x+)
  1716.                         CX     delay (default=1)
  1717.                         DX     retry count (default=3)
  1718.                 0Ch     General IOCTL (DOS 3.3 [3.2?]) allows a device driver to
  1719.                         prepare, select, refresh, and query Code Pages
  1720.                 0Dh     Block Device Request (DOS 3.3+)
  1721.                         BL      drive number (0=default)
  1722.                         CH      major subfunction
  1723.                         CL      minor subfunction
  1724.                                 40h set device parameters
  1725.                                 41h write logical device track
  1726.                                 42h format and verify logical device track
  1727.                                 60h get device parameters
  1728.                                 61h read logical device track
  1729.                                 62h verify logical device track
  1730.                         DS:DX   pointer to parameter block
  1731.                 0Eh     Get Logical Device (DOS 3.3+)
  1732.                         BL      drive number (0=default)
  1733.                         return  AL=0 block device has only one logical drive
  1734.                                 assigned 1..n the last letter used to reference
  1735.                                 the device (1=A:,etc)
  1736.                 0Fh     Set Logical Device (DOS 3.3+)
  1737.         BL      drive number:  0=default, 1=A:, 2=B:, etc.
  1738.         BX      file handle
  1739.         CX      number of bytes to read or write
  1740.         DS:DX   data or buffer
  1741.         DX      data
  1742. return  AX      number of bytes transferred
  1743.                 or error code (call function 59h for extended error codes)
  1744.                 or status  00h     not ready
  1745.                            0FFh    ready
  1746.         CF      set if error
  1747.  
  1748.  
  1749. Function  45h   Duplicate a File Handle (DUP)
  1750. entry   AH      45h
  1751.         BX      file handle to duplicate
  1752. return  CF      clear   AX      duplicate handle
  1753.                 set     AX      error code  (4, 6)
  1754. note 1) If you move the pointed of one handle, the pointer of the other will
  1755.         also be moved.
  1756.      2) The handle in BX must be open
  1757.  
  1758.  
  1759. Function  46h   Force Duplicate of a Handle (FORCEDUP or CDUP)
  1760.                 Forces handle in CX to refer to the same file at the same
  1761.                 position as BX
  1762. entry   AH      46h
  1763.         BX      existing file handle
  1764.         CX      new file handle
  1765. return  CF      clear   both handles now refer to existing file
  1766.                 set     error
  1767.                 AX      error code (4, 6)
  1768. note 1) If CX was an open file, it is closed first
  1769.      2) If you move the read/write pointer of either file, both will move
  1770.      3) The handle in BX must be open
  1771.  
  1772.  
  1773. Function  47h   Get Current Directory
  1774.                 Places full pathname of current directory/drive into a buffer
  1775. entry   AH      47h
  1776.         DL      drive (0=default, 1=A:, etc.)
  1777.         DS:SI   points to 64-byte buffer area
  1778. return  CF      clear   DS:DI   pointer to ASCIIZ pathname of current directory
  1779.                 set     AX      error code (0Fh)
  1780. note   String does not begin with a drive identifier or a backslash
  1781.  
  1782.  
  1783. Function  48h   Allocate Memory
  1784.                 Allocates requested number of 16-byte paragraphs of memory
  1785. entry   AH      48h
  1786.         BX      number of 16-byte paragraphs desired
  1787. return  CF      clear   AX      segment address of allocated space
  1788.                         BX      maximum number paragraphs available
  1789.                 set     AX      error code (7, 8)
  1790. note    BX indicates maximum memory availible only if allocation fails
  1791.  
  1792.  
  1793. Function  49h   Free Allocated Memory
  1794.                 Frees specified memory blocks
  1795. entry   AH      49h
  1796.         ES      segment address of area to be freed
  1797. return  CF      clear   successful
  1798.                 set     AX      error code (7, 9)
  1799. note 1) This call is only valid when freeing memory obtained by function 48h.
  1800.      2) A program should not try to release memory not belonging to it.
  1801.  
  1802.  
  1803. Function  4Ah   Modify Allocated Memory Blocks (SETBLOCK)
  1804.                 Expand or shrink memory for a program
  1805. entry   AH      4AH
  1806.         BX      new size in 16 byte paragraphs
  1807.         ES      segment address of block to change
  1808. return  CF      clear   nothing
  1809.                 set     AX      error code (7, 8, 9)
  1810.                     or  BX      max number paragraphs available
  1811. note 1) Max number paragraphs availible is returned only if the call fails
  1812.      2) Memory can be expanded only if there is memory availible
  1813.  
  1814.  
  1815. Function  4Bh   Load or Execute a Program  (EXEC)
  1816. entry   AH      4Bh
  1817.         AL      00h     load and execute program. A PSP is built for the program
  1818.                         the ctrl-break and terminate addresses are set to the
  1819.                         new PSP.
  1820.                *01h     load but don't execute  (note 1)
  1821.                *01h     load but don't execute (internal, DOS 3.x & DESQview)
  1822.                *02h     load but do not execute (internal, DOS 2.x only)
  1823.                 03h     load overlay (do not create PSP, do not begin execution)
  1824.         DS:DX   points to the ASCIIZ string with the drive, path, and filename
  1825.                 to be loaded
  1826.         ES:BX   points to a parameter block for the load
  1827.                (AL=00h) word    segment address of environment string to be
  1828.                                 passed
  1829.                        dword    pointer to the command line to be placed at
  1830.                                 PSP+80h
  1831.                        dword    pointer to default FCB to be passed at PSP+5Ch
  1832.                        dword    pointer to default FCB to be passed at PSP+6Ch
  1833.               (*AL=01h) word    segment of environment (0 = use current)
  1834.                        dword    pointer to command line
  1835.                        dword    pointer to FCB 1
  1836.                        dword    pointer to FCB 2
  1837.                        dword    will hold SS:SP on return
  1838.                        dword    will hold program entry point (CS:IP) on return
  1839.               (*AL=02h) word    segment of environment (0 = use current)
  1840.                        dword    pointer to command line
  1841.                        dword    pointer to FCB 1
  1842.                        dword    pointer to FCB 2
  1843.                (AL=03h) word    segment address where file will be loaded
  1844.                         word    relocation factor to be applied to the image
  1845. return  CF      set     error
  1846.                         AX      error code (1, 2, 8, 0Ah, 0Bh)
  1847. note 1) If you make this call with AL=1 the program will be loaded as if you
  1848.         made the call with AL=0 except that the program will not be executed.
  1849.         Additionally, with AL=1 the stack segment and pointer along with the
  1850.         program's CS:IP entry point are returned to the program which made the
  1851.         4B01h call. These values are put in the four words at ES:BX+0Eh. On
  1852.         entry to the call ES:BX points to the environment address, the command
  1853.         line and the two default FCBs. This form of EXEC is used by DEBUG.COM.
  1854.      2) Application programs may invoke a secondary copy of the command
  1855.         processor (normally COMMAND.COM) by using the EXEC function.  Your
  1856.         program may pass a DOS command as a parameter that the secondary
  1857.         command processor will execute as though it had been entered from the
  1858.         standard input device.
  1859.         The procedure is:
  1860.          A. Assure that adequate free memory (17k for 2.x and 3.0, 23k for 3.1
  1861.             up) exists to contain the second copy of the command processor and
  1862.             the command it is to execute. This is accomplished by executing
  1863.             function call 4Ah to shrink memory allocated to that of your current
  1864.             requirements. Next, execute function call 48h with BX=0FFFFh. This
  1865.             returns the amount of memory availible.
  1866.         B. Build a parameter string for the secondary command processor in the
  1867.            form:
  1868.                          1 byte   length of parameter string
  1869.                         xx bytes  parameter string
  1870.                          1 byte   0Dh (carriage return)
  1871.            For example, the assembly language statement below would build the
  1872.            string to cause execution of the command FOO.EXE:
  1873.                               DB 19,"/C C:FOO",13
  1874.         C. Use the EXEC function call (4Bh), function value 0 to cause execution
  1875.            of the secondary copy of the command processor. (The drive,
  1876.            directory, and name of the command processor can be gotten from the
  1877.            COMSPEC variable in the DOS environment passed to you at PSP+2Ch.)
  1878.         D. Remember to set offset 2 of the EXEC control block to point to the
  1879.            string built above.
  1880.      3) All open files of a process are duplicated in the newly created
  1881.         process after an EXEC, except for files originally opened with the
  1882.         inheritance bit set to 1.
  1883.      4) The environment is a copy of the original command processor's
  1884.         environment. Changes to the EXECed environment are not passed back to
  1885.         the original. The environment is followed by a copy of the DS:DX
  1886.         filename passed to the child process. A zero value will cause the
  1887.         child process to inherit the environment of the calling process. The
  1888.         segment address of the environment is placed at offset 2Ch of the
  1889.         PSP of the program being invoked.
  1890.      5) This function uses the same resident part of COMMAND.COM, but makes a
  1891.         duplicate of the transient part.
  1892.      6) How EXEC knows where to return to: Basically the vector for int 22h
  1893.         holds the terminate address for the current process. When a process
  1894.         gets started, the previous contents of int 22h get tucked away in the
  1895.         PSP for that process, then int 22h gets modified. So if Process A
  1896.         EXECs process B, while Process B is running, the vector for int 22h
  1897.         holds the address to return to in Process A, while the save location in
  1898.         Process B's PSP holds the address that process A will return to when
  1899.         *it* terminates. When Process B terminates by one of the usual legal
  1900.         means, the contents of int 22h are (surmising) shoved onto the stack,
  1901.         the old terminate vector contents are copied back to int 22h vector from
  1902.         Process B's PSP, then a RETF or equivalent is executed to return control
  1903.         to process A.
  1904.      7) To load an overlay file with 4B: first, don't de-allocate the memory
  1905.         that the overlay will load into. With the other 4Bh functions, the
  1906.         opposite is true--you have to free the memory first, with function 4Ah.
  1907.         Second, the "segment address where the file will be loaded" (first item
  1908.         in the parameter block for sub-function 03) should be a paragraph
  1909.         boundary within your currently-allocated memory. Third, if the
  1910.         procedures within the overlay are FAR procs (while they execute, CS will
  1911.         be equal to the segment address of the overlay area), the relocation
  1912.         factor should be set to zero. On the other hand, if the CS register
  1913.         will be different from the overlay area's segment address, the
  1914.         relocation factor should be set to represent the difference. You
  1915.         determine where in memory the overlay file will load by using the
  1916.         segment address mentioned above. Overlay files are .EXEs (containing
  1917.         header, relocation table, and memory image).
  1918.      8) When function 00h returns, all registers are changed, including the
  1919.         stack. You must resore SS, SP, and any other required registers.
  1920.  
  1921.  
  1922. Function  4Ch   Terminate a Process (EXIT)
  1923.                 Quit with ERRORLEVEL exit code
  1924. entry   AH      4Ch
  1925.         AL      exit code in AL when called, if any, is passed to next process
  1926. return  none
  1927. note 1) Control passes to DOS or calling program
  1928.      2) return code from AL can be retrieved by ERRORLEVEL or function 4Dh
  1929.      3) all files opened by this process are closed, buffers are flushed, and
  1930.         the disk directory is updated
  1931.      4) Restores Terminate vector from PSP:000Ah
  1932.                  Ctrl-C vector from PSP:000Eh
  1933.                  Critical Error vector from PSP:0012h
  1934.  
  1935.  
  1936. Function  4Dh   Get Return Code of a Subprocess (WAIT)
  1937.                 Gets return code from functions 31h and 4Dh  (ERRORLEVEL)
  1938. entry   AH      4Dh
  1939. return  AL      exit code of subprogram (functions 31h or 4Ch)
  1940.         AH      circumstance which caused termination
  1941.                 00h     normal termination
  1942.                 01h     control-break
  1943.                 02h     critical device error
  1944.                 03h     terminate and stay resident (function 31h)
  1945. note    The exit code is only returned once
  1946.  
  1947.  
  1948. Function  4Eh   Find First Matching File (FIND FIRST)
  1949. entry   AH      4Eh
  1950.         CX      search attributes
  1951.         DS:DX   pointer to ASCIIZ filename (with attributes)
  1952. return  CF      set     AX      error code (2, 12h)
  1953.                 clear   data block written at current DTA
  1954.                         format of block is:  (info from BIX)
  1955.   documented by Micro-  |00h   1 byte   attribute byte of search
  1956.   soft as "reserved for |01h   1 byte   drive letter for search
  1957.   DOS' use on subsquent |02h   11 bytes the search name used
  1958.   Find Next calls"      |0Ch   2 bytes  word value of last entry
  1959.   function 4Fh          |0Fh   4 bytes  dword pointer to this DTA
  1960.                         |13h   2 bytes  word directory start
  1961.                         | PC-DOS 3.10 (from INTERRUP.ARC)
  1962.                         |00h   1 byte   drive letter
  1963.                         |01h-0Bh    bytes  search template
  1964.                         |0Ch   1 byte   search attributes
  1965.                         | DOS 2.x (and DOS 3.x except 3.1?) (from INTERRUP.ARC)
  1966.                         |00h   1 byte   search attributes
  1967.                         |01h   1 byte   drive letter
  1968.                         |02h-0Ch bytes  search template
  1969.                         |0Dh-0Eh 2 bytes entry count within directory
  1970.                         |0Fh-12h   bytes reserved
  1971.                         |13h-14h 2 bytes cluster number of parent directory
  1972.  
  1973.                          15h   1 byte   file attribute
  1974.                          16h   2 bytes  file time
  1975.                          18h   2 bytes  file date
  1976.                          1Ah   2 bytes  low word of file size
  1977.                          1Ch   2 bytes  high word of file size
  1978.                          1Eh  13 bytes  name and extension of file found, plus
  1979.                                         1 byte of 0s. All blanks are removed
  1980.                                         from the name and extension, and if an
  1981.                                         extension is present it is preceded by a
  1982.                                         period.
  1983. note 1) Will not find volume label
  1984.      2) This function does not support network operations
  1985.      3) Wildcards are allowed in the filespec
  1986.      4) If the attribute is zero, only ordinary files are found. If the volume
  1987.         label bit is set, only volume labels will be found. Any other attribute
  1988.         will return that attribute and all normal files together.
  1989.      5) To look for everything except the volume label, set the hidden, system,
  1990.         and subdirectory bits all to 1
  1991.  
  1992.  
  1993. Function  4Fh   Find Next Matching File (FIND NEXT)
  1994.                 Find next ASCIIZ file
  1995. entry   AH      4Fh
  1996. return  CF      clear   data block written at current DTA
  1997.                 set     AX      error code (2, 12h)
  1998. note 1) If file found, DTA is formatted as in call 4Eh
  1999.      2) Volume label searches using 4Eh/4Fh reportedly aren't 100% reliable
  2000.         under DOS 2.x. The calls sometime report there's a volume label and
  2001.         point to a garbage DTA, and if the volume label is the only item they
  2002.         often won't find it
  2003.      3) This function does not support network operations
  2004.      4) Use of this call assumes that the original filespec contained wildcards
  2005.  
  2006.  
  2007. Function  50h   "Used Internally by DOS" - Set PSP
  2008.  *              Set new Program Segment Prefix (current Process ID)
  2009. entry   AH      50h
  2010.         BX      segment address of new PSP
  2011. return  none - swaps PSP's regarded as current by DOS
  2012. note 1) By putting the PSP segment value into BX and issuing call 50h DOS stores
  2013.         that value into a variable and uses that value whenever a file call is
  2014.         made.
  2015.      2) Note that in the PSP (or PDB) is a table of 20 (decimal) open file
  2016.         handles. The table starts at offset 18h into the PSP. If there is an
  2017.         0FFh in a byte then that handle is not in use. A number in one of the
  2018.         bytes is an index into an internal FB table for that handle. For
  2019.         instance the byte at offset 18h is for handle 0, at offset 19h handle
  2020.         1, etc. up to 13h. If the high bit is set then the file associated by
  2021.         the handle is not shared by child processes EXEC'd with call 4Bh.
  2022.      3) Function 50h is dangerous in background operations prior to DOS 3.x as
  2023.         it uses the wrong stack for saving registers.  (same as functions
  2024.         0..0Ch in DOS 2.x)
  2025.      4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler
  2026.         without setting the Critical Error flag
  2027.      5) Open File information, etc. is stored in the PSP DOS views as current.
  2028.         If a program (eg. a resident program) creates a need for a second PSP,
  2029.         then the second PSP should be set as current to make sure DOS closes
  2030.         that as opposed to the first when the second application finishes.
  2031.      6) See PC Mag Vol.5, No 9, p.314 for discussion.
  2032.      7) Used by DOS 3.3 PRINT & DEBUG, DesQview 2.01, Windows 1.03, SYMDEB
  2033.         from MASM 4.0
  2034.  
  2035.  
  2036. Function  51h    "Used Internally by DOS" - Get Program Segment Prefix
  2037.  *               Returns the PSP address of currently executing program
  2038. entry   AH      51h
  2039. return  BX      address of currently executing program
  2040.                 offset
  2041.                 00h     program exit point
  2042.                 02h     memory size in paragraphs
  2043.                 04h     unused (0)
  2044.                 05h     CP/M style entry point (far call to DOS)
  2045.                 0Ah     terminate address (old int 22h)
  2046.                 0Ch     terminate segment
  2047.                 0Eh     break address (old int 23h)
  2048.                 10h     break segment
  2049.                 12h     error address (old int 24h)
  2050.                 14h     error segment
  2051.                 16h     parent PSP segment
  2052.                 18h     DOS 2.0+ open files, 0FFh = unused
  2053.                 2Ch     DOS 2.0+ environment segment
  2054.                 2Eh     far ptr to process's SS:SP
  2055.                 32h     DOS 3.x max open files
  2056.                 34h     DOS 3.x openfile table address
  2057.                 36h     DOS 3.x openfile table segment
  2058.                 38h     unused by DOS versions <= 3.3
  2059.                 50h     DOS function dispatcher (FAR routine)
  2060.                 53h     unused
  2061.                 55h     FCB #1 extension
  2062.                 5Ch     FCB #1
  2063.                 6Ch     FCB #2
  2064.                 80h     command tail / default DTA buffer
  2065. note 1) Used in DOS 2.x, 3.x uses 62h
  2066.      2) Function 51h is dangerous in background operations prior to DOS 3.x as
  2067.         it uses the wrong stack for saving registers.  (same as functions
  2068.         0..0Ch in DOS 2.x)
  2069.      3) 50h and 51h might be used if you have more than one process in a PC.
  2070.         For instance if you have a resident program that needs to open a file
  2071.         you could first call 51h to save the current id and then call 50h to set
  2072.         the ID to your PSP.
  2073.      4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler
  2074.         without setting the Critical Error flag
  2075.      5) Used by DOS 3.3 PRINT, DEBUG
  2076.  
  2077.  
  2078. Function  52h   "Used Internally by DOS" - IN-VARS
  2079.  *              Returns a pointer to a set of DOS data variables MCB chain,
  2080.                 pointer to first device driver and a pointer to disk parameter
  2081.                 blocks (first one)
  2082. entry   AH      52h
  2083. return  ES:BX   pointer to the DOS list of lists, for disk information. Does not
  2084.                 access the disk, so information in tables might be incorrect if
  2085.                 disk has been changed. Returns a pointer to the following array
  2086.                 of longword pointers:
  2087.                 Bytes   Value
  2088.                 -2h,-1h segment of first memory control block
  2089.                 00h-03h pointer to first DOS disk block (see function 36h)
  2090.                 04h-07h Pointer to list of DOS file tables
  2091.                         dword   pointer to next file table
  2092.                         word    number of files in this table
  2093.                                 35h bytes per file
  2094.                                 00h-01h number of file handles referring to
  2095.                                         this file
  2096.                                 02h-06h unknown
  2097.                                 07h-0Ah pointer to device driver header if
  2098.                                         character device; pointer to DOS Device
  2099.                                         Control Block if block device (see
  2100.                                         fn 32h for format)
  2101.                                 0Bh-1Fh unknown
  2102.                                 20h-2Ah filename in FCB format (no path, no
  2103.                                         period, blank-padded)
  2104.                                 2Bh-2Ch PSP segment of file's owner
  2105.                                 2Dh-30h unknown -  0 always
  2106.                                 31h-32h unknown
  2107.                                 33h-34h unknown
  2108.                 8h-0Bh  pointer to CLOCK$ device driver, whether installable or
  2109.                         resident
  2110.                 0Ch-0Fh pointer to actual CON: device driver, whether
  2111.                         installable or resident
  2112.         (DOS 2.x)
  2113.                 10      number of logical drives in system
  2114.                 11-12   maximum bytes/block of any block device
  2115.                 13-16   unknown
  2116.                 17      beginning (not a pointer. The real beginning!) of NUL
  2117.                         device driver. This is the first device on DOS's linked
  2118.                         list of device drivers.
  2119.         (DOS 3.x)
  2120.                 10h-11h maximum bytes/block of any block device (0200h)
  2121.                 12h-15h pointer to first disk buffer
  2122.                 16h-19h partially undefined: Pointer to array of drive info:
  2123.                         51h bytes per drive, starting with A: ...
  2124.                         00h-3Fh current path as ASCIIZ, starting with 'x:\'
  2125.                         40h-43h unknown    zeros always
  2126.                         44h     unknown    flags? Usually 40h, except for
  2127.                                 entry after last valid entry = 00h
  2128.                         45h-48h pointer to DOS disk block for this drive
  2129.                         49h-4Ah unknown. Current track or block?
  2130.                                 -1 if never accessed
  2131.                         4Bh-4Eh unknown  -1 always
  2132.                         4Fh-52h unknown   2 always
  2133.                 1Ah-1Dh pointer to FCB table (if CONFIG.SYS contains FCBS=)
  2134.                 1Eh-1Fh size of FCB table
  2135.                 20h     number of block devices
  2136.                 21h     value of LASTDRIVE command in CONFIG.SYS (default 5)
  2137.                 22h     beginning (not a pointer. The real beginning!) of NUL
  2138.                         device driver. This is the first device on DOS's linked
  2139.                         list of device drivers.
  2140. note 1) This call is not supported in OS/2 1.0's DOS Compatibility Box
  2141.      2) Used by DOS 4.0 MEM.EXE, DOS 3.3 ASSIGN.COM, PRINT.COM, SUBST.EXE
  2142.      3) IMPORTANT:  The structure of this list changes with EVERY version of
  2143.         DOS.  It is only partially supported by DR-DOS, and isn't supported
  2144.         under PC-MOS, OS/2's DOS box, or Wendin-DOS.  Since the information
  2145.         changes so much, I feel it should be put in the "interesting, but
  2146.         not real useful" category.  If you depend on this stuff in production
  2147.         code, you're going to regret it.
  2148.  
  2149.  
  2150. Function  53h   "Used Internally by DOS" - Translate BPB
  2151.  *              Translates BPB (BIOS Parameter Block, see below) into a DOS Disk
  2152.                 Block (see function call 32h).
  2153. entry   AH      53h
  2154.         DS:SI   pointer to BPB
  2155.         ES:BP   pointer to area for DOS Disk Block.
  2156.                 Layout of Disk Block:
  2157.                 bytes   value
  2158.                 00h-01h bytes per sector, get from DDB bytes 02h-03h.
  2159.                 02h     sectors per cluster, get from (DDB byte 4) + 1
  2160.                 03h-04h reserved sectors, get from DDB bytes 06h-07h
  2161.                 05h     number of FATs, get from DDB byte 08h
  2162.                 06h-07h number of root dir entries, get from DDB bytes 09h-0Ah
  2163.                 08h-09h total number of sectors, get from:
  2164.                         ((DDB bytes 0Dh-0Eh) - 1) * (sectors per cluster (BPB
  2165.                         byte 2)) + (DDB bytes 0Bh-0Ch)
  2166.                 0Ah     media descriptor byte, get from DDB byte 16h
  2167.                 0Bh-0Ch number of sectors per FAT, get from DDB byte 0Fh
  2168. return  unknown
  2169.  
  2170.  
  2171. Function  54h   Get Verify Setting
  2172.                 Get verify flag status
  2173. entry   AH      54h
  2174. return  AL      00h if flag off
  2175.                 01h if flag on
  2176. note    Flag can be set with function 2Eh
  2177.  
  2178.  
  2179. Function  55h   "Used Internally by DOS" - Create "Child" PSP
  2180.  *              Create PSP: similar to function 26h (which creates a new Program
  2181.                 Segment Prefix at segment in DX) except creates a "child" PSP
  2182.                 rather than copying the existing one.
  2183. entry   AH      55h
  2184.         DX      segment number at which to create new PSP.
  2185. return  unknown
  2186. note 1) This call is similar to call 26h which creates a PSP except that unlike
  2187.         call 26h the segment address of the parent process is obtained from the
  2188.         current process ID rather than from the CS value on the stack (from the
  2189.         INT 21h call). DX has the new PSP value and SI contains the value to be
  2190.         placed into PSP:2 (top of memory).
  2191.      2) Function 55 is merely a substitute for function 26h. It will copy the
  2192.         current PSP to the segment address DX with the addition that SI is
  2193.         assumed to hold the new memory top segment. This means that function
  2194.         26h sets SI to the segment found in the current PSP and then calls
  2195.         function 55h.
  2196.  
  2197.  
  2198. Function  56h   Rename a File
  2199. entry   AH      56h
  2200.         DS:DX   pointer to ASCIIZ old pathname
  2201.         ES:DI   pointer to ASCIIZ new pathname
  2202. return  CF      clear   successful rename
  2203.                 set     AX      error code (2, 3, 5, 11h)
  2204. note 1) Works with files in same drive only
  2205.      2) Global characters not allowed in filename
  2206.      3) The name of a file is its full pathname. The file's full pathname can
  2207.         be changed, while leaving the actual FILENAME.EXT unchanged. Changing
  2208.         the pathname allows the file to be "moved" from subdirectory to
  2209.         subdirectory on a logical drive without actually copying the file.
  2210.      4) DOS 3.x allows renaming of directories
  2211.  
  2212.  
  2213.